Integration of was 6 and WebSphere mq6

Source: Internet
Author: User
Tags websphere application server
Integration of was 6 and WebSphere mq6

Bromon originality, please respect copyright

The purpose of integration is to make MQ the JMS provider of Websphere Application Server. All JMS messages will be forwarded to the MQ queue by was. Because MQ provides APIs on multiple platforms, therefore, the message can no longer be transferred. Any platform can directly connect to mq to get/send messages, reducing the uncertain factors in cross-platform message transmission.

First, establish the queue manager, message queue, and server connection channel (system. Def. svrconn channel) in MQ ). Because was will communicate with MQ in client mode, you need to configure the Mac user ID on the channel for identity authentication, the value should be the user name of the operating system that runs MQ. The user should have administrator permissions. We recommend that you use the user name that starts MQ. If this Mac user ID is not configured, the machine running was must create a user/password identical to that running MQ to start was to provide the correct identity information. If the bindinf transmission mode is used, no authentication information is required. However, this mode can only be applied to the situation of was and MQ on the same machine. In a was environment, only one connection factory can be connected in binding mode. Therefore, this mode is not recommended.
Assume that the created queue manager is sobeymam, The ccsid is 1208 (UNICODE) or 1381 (gb2312), the communication port is 1414, the created message queue is test, and the ccsid is 1208 (UNICODE ); the server connection channel is S1, And the Mac user ID is bromon.

The next step is to establish a queue connection factory in was, "resource" ---- "JMS provider" ---- "WebSphere MQ" ---- "WebSphere MQ queue connection factory" ---- "new ". Enter the following content:

Name: Cf
JNDI name: JMS/CF
Queue Manager: mam
HOST: Name or IP address of the machine that runs MQ
Port: 1414 (corresponding to the listening port of the queue manager)
Channel: S1 (corresponding to the server connection channel of the queue manager)
Transmission type: Client
Cancel the "started xa" option

The connection factory configuration is complete.

The next step is to create a queue target. "Resource" ---- "JMS provider" ---- "WebSphere MQ" ---- "WebSphere MQ queue target" ---- "new ". Enter the following content:

Name: Test
JNDI name: JMS/test
Basic queue name: Test (corresponding to the local queue in MQ)
Ccsid: 1208
Target client: MQ

The queue target is configured. It should be noted that the value of the target client determines the format in which the JMS message will be stored in MQ. For "MQ", messages are stored in plain text in mqstr format. messages can be directly displayed on any platform. If the message is "JMS", the message will be stored in the mshrf2 format. The Java platform can recognize the message without processing. Other platforms must convert the message to obtain the message text correctly. We recommend that you use "MQ ".

If you need to deploy a message Bean to retrieve messages in MQ, you also need to configure the listener port, "server" ---- "Application Server" ---- "server1" ---- "communication" ---- "message transmission" ---- "message listener service" ---- "listener port" ---- "new ". Enter the following content:

Name: Test
Connection factory JNDI name: JMS/CF (corresponding to the jndi of the WebSphere queue connection factory)
Target JNDI name: JMS/test (corresponding to the jndi of the WebSphere queue target)

Listener port configuration is complete. The Listener name must be provided when message Bean is deployed.

Restart Websphere to make the configuration take effect.

Write a JSP to try to send a message:

  1. <% @ Page contenttype = "text/html; charset = GBK" %>
  2. <% @ PageImport= "Java. util. *" %>
  3. <% @ PageImport= "Javax. JMS. *" %>
  4. <% @ PageImport= "Javax. Naming. *" %>
  5. <%
  6. Try
  7. {
  8. Properties P =NewProperties ();
  9. P. Put (context. initial_context_factory, "com. IBM. websphere. Naming. wsninitialcontextfactory ");
  10. P. Put (context. url_pkg_prefixes, "com. IBM. ws. Naming ");
  11. P. Put (context. provider_url, "IIOP: // localhost: 2809 /");
  12. Initialcontext CTX =NewInitialcontext (P );
  13. Queueconnectionfactory qcf = (queueconnectionfactory) CTX. Lookup ("JMS/CF ");// Connect to the factory
  14. Queueconnection conn = qcf. createqueueconnection ();
  15. Queue q = (Queue) CTX. Lookup ("JMS/test ");// Queue
  16. Queuesession S = conn. createqueuesession (False, Queuesession. auto_acknowledge );
  17. Conn. Start ();
  18. Queuesender sender = S. createsender (Q );
  19. Textmessage TM = S. createtextmessage ("test that WebSphere MQ has Chinese characters ");// Create a text message
  20. Sender. Send (TM, deliverymode. Persistent, 4, 0 );
  21. Sender. Close ();
  22. }Catch(ExceptionE)
  23. {
  24. Out. println (E );
  25. }
  26. %>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.