Guest User

Untitled

a guest
Jan 23rd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. public static void main(String[] args) throws JMSException {
  2. // TODO Auto-generated method stub
  3.  
  4. try{
  5. MQEnvironment.disableTracing();
  6. MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
  7. cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, "localhost");
  8. cf.setStringProperty(WMQConstants.WMQ_PORT, "1414");
  9. cf.setStringProperty(WMQConstants.WMQ_CHANNEL, "TEST_SVR_CONN");
  10. cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, "DEVTESTQUEUE");
  11. //cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_DIRECT_HTTP);
  12. //cf.setTransportType(WMQConstants.WMQ_CM_BINDINGS);
  13. //set MQServer =
  14. //HelloWorldConsumer.HelloWorldProducer();
  15. MQQueueConnection connection = (MQQueueConnection) cf.createQueueConnection();
  16. MQSession session = (MQSession) connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
  17. MQQueue queue = (MQQueue) session.createQueue("REQUEST");
  18. //queue.setMessageBodyStyle(WMQConstants.WMQ_MESSAGE_BODY_MQ);
  19. queue.setTargetClient(WMQConstants.WMQ_TARGET_DEST_MQ);
  20. queue.setProperty("PROPCTL", "ALL");
  21. ((com.ibm.mq.jms.MQQueue)queue).setIntProperty(WMQConstants.WMQ_TARGET_CLIENT, WMQConstants.WMQ_TARGET_DEST_MQ);
  22. connection.start();
  23. MessageConsumer consumer = session.createConsumer(queue);
  24. consumer.setMessageListener(new HelloWorldConsumer());
  25. session.close();
  26. connection.close();
  27. System.out.println("------END------");
  28. }catch(JMSException je){
  29. je.printStackTrace();
  30. }catch(Exception e){
  31. e.printStackTrace();
  32. }
  33. }
Add Comment
Please, Sign In to add comment