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

Compare with Current View Page History

« Previous Version 58 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

\\ Then type:

servicemix_install_dir\bin\servicemix servicemix.xml

where {{servicemix_install_dir}} is the directory in which Service Mix was installed.
\\
\\
h2. Stopping the _Basic_ Example
To terminate the Basic example type "CTRL-C" in the command shell in which it is running.
\\
\\

h2. How it Works
The diagram illustrates the flow of messages through the _Basic_ components.
\\
\\

{panel:title= Basic Example Message Flow Diagram|borderStyle=solid|borderColor=#ccc}
!basicflow.jpg|align=center!
{panel}

\\
\\

Messages flow through the components as follows:
# The _timer_ component sends a Normalized Message (NM) to _inputSender_ through the Normalized Message Router (NMR).
# _inputSender_ converts the message (marshals it) into a JMS message, then uses the _jmsTemplate_ bean to publish the message. 
# _jmsTemplate_ uses the _jmsFactory_ bean to get a connection factory to the port associated with the JMS topic called "demo.org.servicemix.source." The message is published on the "demo.org.servicemix.source" topic.
# _jencks_ listens on port 61616 for messages.
# _inputReceiver_ subscribes to the "demo.org.servicemix.source" topic via the _jencks_ bean and receives the JMS message.
# _inputReceiver_ normalizes the JMS message and sends it to _outputSender_ via the NMR.
# _outputSender_ marshals the NM to a JMS message and uses _jmsTemplate_ to publish the message on the "demo.org.servicemix.result" topic.
# _jmsTemplate_ publishes it on the "demo.org.servicemix.result" topic using _jmsFactory_ to get a connection factory to the result topic.
# _jencks_ listens on port 61616 for messages.
# _jmsTrace_, via _jencks_, subscribes to the "demo.org.servicemix.result" topic and receives the JMS message.
# _jmsTrace_ converts the JMS message into a normalized message and sends it to _trace_ via the NMR.
# _trace_ transforms the normalized message into a string and logs it to the console.
\\

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>}}

 

Details

The following table provides more details about the 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 ... to 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

Receives normalized messages from jmsTrace via the NMR. It transforms the normalized message into a string and logs

 

 

 

 

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.



Related Documentation

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

  • No labels