You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 26 Next »

Overview of the Basic Example

This document describes how the Basic example is used and provides details about what it does.
The source code for the Basic example is stored in the Service Mix installation directory under the examples\basic directory in the servicemix.xml file.

cd servicemix_install_dir\examples\basic

To run it:

servicemix_install_dir\bin\servicemix servicemix.xml

where [servicemix_install_dir] is the location in which Service Mix was installed.
\\
\\
h3. Stopping the _Basic_ Example
To terminate the Basic example type "CTRL-C" in the command shell in which it is running.
\\
\\

h3. How it Works
The diagram illustrates the components of the Basic example and how they interact with each other within the JBI container.
\\
\\
 A DIAGRAM WILL BE PUT HERE--still creating
\\
\\
The following table explains the basic function of each component and bean in the servicemix.xml file.
||Component or Bean ID||Description||
|_jbi_|The _jbi_ container contains the following components: _timer_, _inputSender_, _inputReceiver_, _outputSender_, _jmsTrace_, and _trace_. First the servicemix.xml file initializes the _jbi_ container by setting several properties. Then the components are run. Note: During the initialization, a bean called "transactionManager" is instantiated. The _transactionManager_ provides the connectivity between the JMS messaging system and the _jbi_ container. |
|_timer_|Every 5 seconds, until the program is terminated, the timer component kicks off a trigger. The job has a property called "name" with a value of "My Example Job" and another property called "group" with a value of "ServiceMix." The trigger is converted to a normalized message and routed through the Normalized Message Router (NMR).|
|_inputSender_|Receives the normalized message (the trigger), converts it to a JMS message, and publishes it to the topic called demo.org.servicemix.source.|
|_inputReceiver_|This component uses the bean called _jencks_ , which is a JCA container, to listen on port 61616 for a JMS message on the topic called "demo.org.servicemix.source." Essentially, _inputReceiver_ subscribes to the demo.org.servicemix.source topic. It takes the message, normalizes it, and routes it to _outputSender_ via the NMR. This component combined with _outputSender_ and some supporting beans creates a JMS bridge between two topics.|
|_outputSender_|This component receives a normalized message from the NMR, marshals it into a JMS message using _jmsTemplate_, then publishes it on the ActiveMQ (JMS) topic called "demo.org.servicemix.result."| 
|_jmsTrace_|This component uses the _jencks_ bean to subscribe to the "demo.org.servicemix.result" topic and get the message that is there. It then marshals the message into a Normalized Message and routes it via the NMR to the _trace_ component.|
|_jmsTrace_|This component uses _jencks_ to listen to port 61616 for the purposes of tracing the messages received on that port.|
|_trace_| |
| | |
| | |
|_jencks_| The _jencks_ bean defines a JCA container.  This bean has two properties, one of which is an ActiveMQ listener, which listens on port 61616. In general a JCA container must provide threading, The JCA |
|_broker_|The _broker_ bean ...|
|_transactionManager_|This bean is invoked in the _jbi_ containers initialization. It instantiates the
org.jencks.factory.TransactionManagerFactoryBean. This bean provides XA transactions between the resource adapter (in this case the ActiveMQ resource adapter) and the _jbi_ container. |
|_jmsFactory_|This bean listens on port 61616.|


When running the _Basic_ example, the typical output looks like the following. Every 5 seconds logging information is written to the console, followed by information from the trace component. Note, that the triggers' property values of "name", "My Example Job", "group", and "ServiceMix" are displayed along with a timestamp.

INFO TraceComponent - -Exchange: org.servicemix.jbi.messaging.InOnlyImpl@b55129 received IN message:
org.servicemix.jbi.messaging.NormalizedMessageImpl@8c9b49{properties: {org.servicemix.jms.message=ACTIVEMQ_TEXT_MESSAGE: id = 0 ActiveMQMessage
{ , jmsMessageID = ID:redmac-2.local-50615-1123857186823-29:1, bodyAsBytes = org.activemq.io.util.ByteArray@b1a22,
readOnlyMessage = true, jmsClientID = 'ID:redmac-2.local-50615-1123857186823-22:0' , jmsCorrelationID = 'null' ,
jmsDestination = demo.org.servicemix.result, jmsReplyTo = null, jmsDeliveryMode = 2, jmsRedelivered = false, jmsType = 'null'
, jmsExpiration = 0, jmsPriority = 4, jmsTimestamp = 1123857193312, properties = {}, readOnlyProperties = true, entryBrokerName =
'ID:redmac-2.local-50615-1123857186823-0:0' , entryClusterName = 'default' , consumerNos = 0, transactionId = 'null' ,
xaTransacted = false, consumerIdentifer = 'ID:redmac-2.local-50615-1123857186823-14:0' , messageConsumed = false,
transientConsumed = true, sequenceNumber = 1, deliveryCount = 1, dispatchedFromDLQ = false, messageAcknowledge =
org.activemq.ActiveMQSession@74b5ee, jmsMessageIdentity = null, producerKey = ID:redmac-2.local-50615-1123857186823-29: },
text = <?xml version="1.0" encoding="UTF-8"?><timer><name>My Example Job</name><group>ServiceMix</group><fullname>ServiceMix.My Example Job
</fullname><description/><fireTime>Fri Aug 12 15:33:12 BST 2005</fireTime></timer>}}

 



Interesting Details

Perhaps I should have a section that might describe in more detail some important but subtle
aspect of the XML code. Will need input from developers. This section may not be applicable to
all examples.

Related Documentation

Please see ..., plus Jira XX for details on fields...

  • No labels