Guide MQ du 13 Novembre 2007 Journée «Support Packs» Les Support Packs IA94 et IA9H Edouard Orcel edouard.orcel@fr.ibm.com IBM France
Plan Présentation XMS Serveurs compatibles : MQ, WMB, WAS, WPS ou WESB Bases de XMS Messages XMS Modèle de développement XMS XMS vs JMS Exemples Performances Quand utiliser XMS? Journée Support Pack 2
XMS www.dotnetguru.org : «XMS (pour IBM Message Service Clients) est une nouvelle API destinée à faciliter l'interopérabilité des produits IBM (au travers du standard Java JMS) avec des systèmes tiers tels que.net ou C/C+ +. Jusque là il n'existait aucun pont de ce type, une modification (sous la forme de services web) s'avérait souvent nécessaire avec le risque de perdre les services offerts par le moteur asynchrone d'origine. "IBM Message Service Client for.net (XMS) enables applications written in any.net language to send and receive JMS messages across IBM WebSphere messaging technologies". XMS ne fonctionne qu'avec une implémentation IBM de JMS (en l'occurrence Websphere MQ). L'outil est disponible en téléchargement (béta).» Journée Support Pack 3
XMS Journée Support Pack 4
XMS avec WebSphere MQ 5.3 et 6.0 WebSphere Message Broker 5 et 6 WebSphere Application Server V6.0 WebSphere Process Server 6 WebSphere ESB 6 Journée Support Pack 5
XMS - in a NUTSHELL Multi Language Messaging Service (XMS) Message-Oriented Middleware (MOM) API for Messaging Created by IBM based on JMS 1.1 specs Purpose is to provide a sophisticated, yet straightforward way to exchange messages between applications. A message is any data or event that applications need to share. Implementation Independent Journée Support Pack 6
Message Oriented Middleware ( MoM) What Does MoM Provide? Proper distribution of messages Fault Tolerance Scalability Transaction Support Asynchronous Delivery De-coupling of the Sender and Receiver Journée Support Pack 7
XMS Glossary XMS Peeling the first layer XMS Application a system comprised of XMS clients and at least one XMS/JMS Provider XMS Provider the MOM with associated XMS classes XMS client messaging clients in a XMS environment Producer a client that produces and sends messages Consumer a client that receives and consumes messages Defines APIs for: Point to Point - Queues Publish/Subscribe - Topics Five message classes TextMessage, BytesMessage, ObjectMessage, StreamMessage, MapMessage User defined message properties Asynchronous message delivery Journée Support Pack 8
XMS/JMS Message - Anatomy Headers Automatically Assigned/Developer Assigned JMS Destination JMS Delivery Mode JMS Message ID JMS Time Stamp JMS Correlation ID JMS Reply To JMS Redelivered JMS Type JMS Expiration JMS Priority Properties XMS supports three kinds of message property: JMS defined properties IBM defined properties Application defined properties. Payload Data Event Journée Support Pack 9
Administered Objects XMS/JMS Business Cards Encapsulate vendor specific details Aids application portability across JMS implementations Can either be Stored externally and accessed by JNDI, allows application to be reconfigured without recompilation, or Can be created at run time, but largely negates intended advantages Connection Factory Describes how to connect to messaging infrastructure Destination Describes an end point for sending to or receiving from Journée Support Pack 10
Generic Programming Model XMS Producer Journée Support Pack 11
Generic Programming Model XMS Consumer Journée Support Pack 12
JMS Sample ConnectionFactory cf = (ConnectionFactory)ctx.lookup(.. ); Connection conn = cf.createconnection(); Queue queue = createqueue( SomeName ); Session sess = conn.createsession(true, Session.AUTO_ACKNOWLEDGE); MessageConsumer mc = sess.createconsumer((destination)queue); conn.start(); ObjectMessage msg = (ObjectMessage) mc.receive(); String msgtxt = (String) msg.getobject(); sess.close(); JMS Vs XMS - Sample XMS Sample rc = xmsconnfactcreate(&hconnfact, xmserror); rc = xmsconnfactcreateconnection(hconnfact, &hconn, xmserror); rc = xmsdestcreatebytype(xmsc_queue, pszqueue, &hdest, xmserror); rc = xmsconncreatesession(hconn, xmsfalse, XMSC_AUTO_ACKNOWLEDGE, &hsess, xmserror); rc = xmssesscreateconsumer(hsess, hdest, &hconsumer, xmserror); rc = xmsconnstart(hconn, xmserror); rc = xmsmsgconsumerreceivewithwait(hconsumer, 10, &hmsg, xmserror); rc = xmsobjectmsggetobjectasbytes(hmsg, pbuff, nlen, &nretlen, xmserror); conn.close(); rc = xmsmsgdispose(&hmsg, xmserror); rc = xmssessclose(&hsess, xmserror); rc = xmsconnclose(&hconn, xmserror); Journée Support Pack 13
An example (cont.) WMQ Connection Factory // Create the connection factories factory XMSFactoryFactory factoryfactory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ XMSC.CT_WMQ); // Use the connection factories factory to create a connection factory IConnectionFactory cf = factoryfactory.createconnectionfactory(); // Set the properties cf.setintproperty(xmsc.wmq_connection_mode, XMSC.WMQ_CM_CLIENT); cf.setstringproperty(xmsc.wmq_host_name, localhost ); cf.setintproperty(xmsc.wmq_port, 1414); cf.setstringproperty(xmsc.wmq_queue_manager, myqueuemanagername ); Journée Support Pack 14
Message selectors Both JMS and XMS let you filter messages using SQL92 selection criteria defined when a MessageConsumer is created. Message selection is performed based on header property values that are set in messages. For example, in the following code fragment, an XMS application written in C sets a string property named Postcode in a message. The property value is SO21 2JN (the postcode for the IBM Hursley lab) : Journée Support Pack 15
Performance Numbers XMS Vs JMS Performance Numbers XMS Vs JMS SCENARIO 1 Sending non-persistent, non-transacted bytes messages from a single producer to a single consumer via a queue destination and measuring the message and bytes throughputs achieved for varying message sizes. Journée Support Pack 16
Performance Numbers XMS Vs JMS Performance Numbers XMS Vs JMS Scenario 1: Data (bytes) throughput for XMS C/C++, XMS.NET and JMS across a range of message sizes: Journée Support Pack 17
Performance Numbers XMS Vs JMS SCENARIO 2 Sending persistent, transacted bytes messages from multiple producers to multiple consumers by way of a single queue destination and measuring the message throughputs achieved at a single 4 KB message body size. Journée Support Pack 18
XMS - When to use Leverage IBM Messaging Middleware from non-java applications Need to interoperate with JMS (and re-use JMS administered objects) Higher abstraction in programming model is preferred Reuse any existing JMS skills To take advantage of the managed.net environment Journée Support Pack 19
XMS - When not to use Use the MQ Interface (MQI) to get widest range of languages & platforms Use the MQI when performance is critical Need to exploit low-level server specific features If using MQe on very small footprint devices Journée Support Pack 20