tag:blogger.com,1999:blog-80280685029206258912024-02-08T09:01:20.014-08:00Ramblings on Open Source Integrationlcurryhttp://www.blogger.com/profile/01568142368502338154noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-8028068502920625891.post-46706335670396746432014-11-11T12:28:00.000-08:002014-11-11T12:32:32.453-08:00<span style="font-family: "Calibri","sans-serif"; font-size: 16.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">CXF Transformations Revisited: Usage within a Camel Route</span><br />
<div class="MsoNormal">
The CXF transformation feature provides a nice way to
declaratively specify certain simple transformations – e.g. replace element
names, add elements, change namespaces, etc. My <a href="http://lowry-techie.blogspot.com/2014/11/overview-of-cxftransformation-feature.html">previous blog post</a> described this mechanism in detail.<br />
This feature makes it easy to
describe the transformation in a map in Spring XML. The ease-of- use in
declaring a transformation with XML makes it a very appealing solution. Such an
easy, declarative mechanism for performing transformations is not available in
Camel.</div>
<div class="MsoNormal">
The out-of-the-box use of CXF transformation feature in a
Camel route is restrictive because the transformation is tied to the CXF
endpoint, so the transformations defined cannot be applied to messages at any
arbitrary location within a route’s pipeline.
</div>
<div class="MsoNormal">
The purpose of this investigation was to determine whether the
API that implements the CXF transformation feature could be de-coupled from CXF
and re-used from within a custom Camel processor to perform transformations on
messages at arbitrary locations within a route.</div>
<span style="font-family: "Calibri","sans-serif"; font-size: 12.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 10.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">A
prototype was written that proves it is indeed possible to use the CXF
transformation feature to define transformation mappings (via XML) using the
same syntax as the CXF feature. The transformation mapping is assigned to a
generic processing bean. The processing bean can then be inserted at any location
within your camel route.</span><br />
<span style="font-family: "Calibri","sans-serif"; font-size: 16.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">Implementation</span><br />
<span style="font-family: "Calibri","sans-serif"; font-size: 12.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 10.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">To implement this pattern, you will define the
transformation in your Spring XML (‘camel-context.xml’) using the transformation
mapping syntax. The mapping language is the same as defined here:</span><br />
<div class="MsoNormal">
<a href="http://cxf.apache.org/docs/transformationfeature.html">http://cxf.apache.org/docs/transformationfeature.html</a></div>
<br />
<div class="MsoNormal">
An example of how this would look in Spring is shown below:</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-2CNDTfIAyjc/VGJv3Fign7I/AAAAAAAAE0o/eKSBOCuv05E/s1600/Untitled_tx_1.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="142" src="https://2.bp.blogspot.com/-2CNDTfIAyjc/VGJv3Fign7I/AAAAAAAAE0o/eKSBOCuv05E/s640/Untitled_tx_1.bmp" width="640" /></a></div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 12.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 10.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">This bean declared above is an instance of the
class “gov.foo.services.enterprise.deqy.transformer.TransformFeature”. This
java class has several properties (expressed as maps) that will hold the logic
required for the transformation.</span></div>
<div class="MsoNormal">
The following code snippet lists the implementation of the
underlying java class represented by the bean declared above.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-2s2hS5e_lZU/VGJwgBf6apI/AAAAAAAAE0w/8qONrZjPQHU/s1600/Untitled_tx_2.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="480" src="https://1.bp.blogspot.com/-2s2hS5e_lZU/VGJwgBf6apI/AAAAAAAAE0w/8qONrZjPQHU/s640/Untitled_tx_2.bmp" width="640" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
The “process()” method (line 20) will get called as the
message passes through the bean. The code will pull out the body of the message
as an XMLStreamReader (line 22-23). Notice line 27 calls the “org.apache.cxf.staxutils.transform.InTransformReader”
constructor with the appropriate maps. This
is where the code re-uses the CXF transformation implementation. The
XMLStreamReader that is returned has been transformed by the CXF API. This is
then set as the body of the message that gets passed along in the route. </div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 12.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 10.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">The
following Camel route ‘camel-context.xml’ expressed in Spring XML, puts it all
together and shows how the transformation can be placed into an arbitrary
location in any route. This route will pick up a file from ‘inbox’ directory,
pass along the content of the file, which is sent to the processing bean that
performs the transformation defined in the same Spring file (shown by the
mapping code shown previously.) The content
of the transformed message will then go to another file component that will
write the content to a file in the outbox ‘directory’.</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-JT1oDHr7Bis/VGJw8UOW7MI/AAAAAAAAE04/dKVi3gtRB2E/s1600/Untitled_tx_4.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="206" src="https://2.bp.blogspot.com/-JT1oDHr7Bis/VGJw8UOW7MI/AAAAAAAAE04/dKVi3gtRB2E/s640/Untitled_tx_4.bmp" width="640" /></a></div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 12.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 10.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 12.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 10.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">The above Camel route ‘camel-context.xml’
expressed in Spring XML, puts it all together and shows how the transformation
can be placed into an arbitrary location in any route. This route (lines 54-58)
contains the processing bean (line 56) that performs the transformation.</span></div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 12.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 10.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;"><br /></span></div>
lcurryhttp://www.blogger.com/profile/01568142368502338154noreply@blogger.com1tag:blogger.com,1999:blog-8028068502920625891.post-43210351550406696652014-11-11T12:16:00.000-08:002014-11-11T12:16:44.273-08:00<div class="MsoNormal" style="margin-left: .5in; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span style="font-size: 16pt; text-indent: -0.25in;">Overview of CXF
Transformation Feature</span></div>
<div class="MsoNormal">
The CXF Transformation feature allows you to declaratively
define a transformation to change namespaces or append/change/drop elements.
The transformation is very much tied to the CXFEndpoint.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-size: 16pt; text-indent: -0.25in;">Intended
Use-cases</span> </div>
<div class="MsoNormal">
The use-cases for which the CXF transformation feature works
well are the following use-cases. </div>
<ol start="1" style="margin-top: 0in;" type="1">
<li class="MsoNormal">Transforming Incoming
Requests from clients - A route exposes an interface to clients via a
WSDL. Some clients may not be
capable of sending messages (or receive response) that adhere to the
interface defined by the route’s WSDL. The CXF transform feature will
allow you to define transformations on the CXFEndpoint so that incoming
non-conforming messages from clients can be transformed and “fixed” to
adhere to the expected interface defined by the WSDL. This allows clients
to send non-conforming messages to the route (e.g. incorrect namespace or
element names) – messages that would otherwise cause an error when sent to
the route - and you can define the appropriate transformation on the
CXFEndpoint to “fix” the incoming requests to conform to WSDL, and
likewise modify outgoing (well-formed) response to something client
expects.</li>
<li><span style="font-family: Calibri, sans-serif; font-size: 12pt;"> </span><span style="font-family: Calibri, sans-serif; font-size: 12pt;">Transforming Outgoing Requests to backend - A
route sends requests to backend service that are well-formed according to a
specific WSDL, but the backend service expects some tweak to what the route is
sending. This could apply for example, in the case where the route’s
CXFEndpoint (client) is ahead of the backend service on changes to element names
or namespaces that adhere to an enterprise standard. At some point the backend
will be updated to accept these changes. However until the backend service is
conformant, the transformation applied to the CXFEndpoint (client) in the route
will tweak the outgoing messages so that they can be understood by the backend
service, and likewise the responses from the backend service can be transformed
as needed into the well-formed format according to the enterprise WSDL.</span></li>
</ol>
<div class="MsoNormal" style="margin-left: .5in; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<span style="font-family: "Calibri","sans-serif"; font-size: 16.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">Transforming
Incoming Requests from clients</span></div>
<div class="MsoNormal">
Let's say we want our route to expose the interface defined
by a new "enterprise" WSDL, and we want to go ahead and deploy that.
Even if there are clients that are not ready to adhere to the new WSDL, clients
can continue to send requests that adhere to the "old" WSDL (e.g.
operation names, different namespace, different element names, etc.) Existing clients can continue to send
requests containing non-conforming messages. </div>
<div class="MsoNormal">
In our new route, we just need to include a mapping in the
spring file that defines the transformation on incoming messages. So as long as
we add the transformation rules into our route, it is able continue to service
clients that don't necessarily adhere to the new WSDL, and (if needed) the
route will modify the messages as defined in the transformation.</div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 12.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 10.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">Below shows the Spring configuration a route
that exposes the interface defined in ‘deqy.wsdl’. Imagine this is our “new” interface. If there
are clients that must continue to call our route that can’t change to the new
WSDL, then the route can be configured (via the Transformation mapping) to
accommodate those existing clients.</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-4fvMVhxrVjY/VGJs9ol6PQI/AAAAAAAAE0M/flkTErofwec/s1600/Untitled1.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="326" src="https://3.bp.blogspot.com/-4fvMVhxrVjY/VGJs9ol6PQI/AAAAAAAAE0M/flkTErofwec/s640/Untitled1.bmp" width="640" /></a></div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 12.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 10.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;"><br /></span></div>
<div class="MsoNormal">
The above code snippet is a ‘camel-context.xml’ (Spring
configuration) for a Camel route that listens on a CXF endpoint. The CXF
endpoint points to a WSDL that defines the route’s interface. The route
includes a CXF transformation map that declaratively defines mappings that
should be done to non-conforming messages as they enter the route. Note the
mappings are defined in such a way that they won’t affect messages that do
adhere to the WSDL. </div>
<div class="MsoNormal">
The above Spring defines a route starting at (line 43) that
begins with a CXF endpoint (listener). The CXF endpoint is defined at lines
32-38 with the transform feature being configured starting at line 35. The individual transformations are defined at
lines (20-29.) </div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 12.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 10.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">As
you can see it is pretty straightforward to configure a route to accommodate
for payload transformation to be applied to incoming messages. Likewise it is
just as easy to apply a transformation for the corresponding response back to
client that will convert the compliant response from the route into a
(potentially non-conformant) response that the client expects.</span></div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 16.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">Transforming
Outgoing Requests to backend</span></div>
<div class="MsoNormal">
For a scenario where a route sends a request to a backend
server, you may have written your route CXFEndpoint (client) that adheres to a
particular WSDL but the backend service for some reason or another needs the
message to be tweaked slightly. To apply
a transformation to a request message before it is written to the wire and a
response before it gets dispatched to the route you can use an outgoing
transform. </div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 12.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 10.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">The
following code shows the implementation of an outgoing transform feature.</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-dFIYKsqzIsk/VGJtw4iybzI/AAAAAAAAE0Y/xd4LKMISpRE/s1600/Untitled2.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="374" src="https://1.bp.blogspot.com/-dFIYKsqzIsk/VGJtw4iybzI/AAAAAAAAE0Y/xd4LKMISpRE/s640/Untitled2.bmp" width="640" /></a></div>
<div class="MsoNormal">
Lines 29-42 define the transform mapping for ‘outTranformElements’
– the mapping on requests as they are sent from route to the backend service,
followed by ‘inTransformElements’ – the mapping on response before the message
re-enters the route. </div>
<div class="MsoNormal">
See lines 44-51 for the CXFEndpoint ‘deqyService’, where the
transform feature is applied (lines 48-50). </div>
<div class="MsoNormal">
The route starts at line 54. The route reads a message from
a file in ‘inbox’ directory, and sends it to the backend service. The route
receives the response, and writes response to a file in ‘outbox’ directory. </div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 12.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 10.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">Consider
a test where the message content of the file dropped into ‘inbox’ conforms to
the WSDL defined on the outgoing
CXFEndpoint – i.e. ‘deqy.wsdl’.
Imagine the backend service requires a tweak to a well-structured
request. For example the namespace the backend service expects in incoming
request and writes to response is different from what is defined in the WSDL.
We can apply any such tweak required by backend service using a transform
defined on the endpoint. In this
scenario the well-formed message we drop into inbox will get transformed just
before it is sent to the backend service based on the transform defined in
‘outTranformElements’. Likewise, the response from backend service gets
transformed based on the ‘inTransformElements’ before the response message
re-enters the route.</span></div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 16.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">A
Workable Solution using CXF transform Feature</span></div>
<div class="MsoNormal">
The following diagram shows how a message flows through a
route that consists of incoming and outgoing CXF Endpoints. Both incoming and
outgoing CXF endpoints have transforms defined.
The location in the flow where the transforms are executed is shown in
the diagram.</div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 12.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 10.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">Consider
a client that is written based on the interface defined by Service ‘A’
WSDL. The client sends a request to the
route using the format based on Service ‘A’ WSDL. The incoming ‘inTransform’
(see position 1 in diagram) will convert messages from the (non-conforming)
format sent by clients, into a format adhering to the Service ‘B’ WSDL. Without
this transform, the incorrectly formatted message sent from client would cause
an operation/binding mis-match when it hit the route’s CXFEndpoint that begins
the route, and this would cause the request to fail on entry to the route.</span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://3.bp.blogspot.com/-yH-O91YU5Rk/VGJuKjThZ4I/AAAAAAAAE0g/nQ5q9B5ExOI/s1600/Untitled3.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="178" src="https://3.bp.blogspot.com/-yH-O91YU5Rk/VGJuKjThZ4I/AAAAAAAAE0g/nQ5q9B5ExOI/s640/Untitled3.bmp" width="640" /></a></div>
<div class="MsoNormal">
The message continues through the route, through Processor A
and B and then reaches the consumer CXFEndpoint. This CXFEndpoint will call the
backend Service ‘B’. The format of the message is correct (adheres to Service
‘B’ WSDL) and Service ‘B’ will respond with correctly formatted message. In
this solution, the ‘outTransform’ and ‘inTransform’ at position 2 and 3 are not
required. </div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 12.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 10.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">The
response from Service ‘B’ flows back into the route, and the response goes
through Processor ‘C’ where a camel-based transformation (e.g. xquery, XSLT,
java code) can be used to transform/enrich the response in any way required.
This transformed message can now be returned back to client. The ‘outTransform’
(position 4) is not necessary in this solution.</span></div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 16.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">Using
CXF in Generic Provider Mode</span></div>
<div class="MsoNormal">
One aspect of the CXF transformation feature that is
problematic is the requirement that you are restricted to performing transformations
that convert message into something that conforms with the WSDL the endpoint is
tied to. If the message is transformed in a way that makes it non-conformant,
an error is thrown when it reaches the endpoint. </div>
<div class="MsoNormal">
In order to make the use of CXF transform easier within
Camel, there is a way to disable the requirement that the incoming message
match the operation/binding of the associated CXFEndpoint. That way, if this message-level
validation is disabled on the Endpoint you can freely apply tranformations to
any format at the endpoint and it will continue to pass through the endpoint
without failure. </div>
<div class="MsoNormal">
You should be careful when over-riding this as the purpose
of a WSDL is to do the operation checking and some special handling based on
the determined operation and also to provide a way for the consumer to get the
typed interface information (i.e., retrieving the WSDL from the endpoint). By
disabling, you will do neither of these, so you could just simply set up your
endpoint using the generic provider mode (i.e., omitting the wsdlURL and
serviceClass properties of the endpoint). </div>
<div class="MsoNormal">
In this case, the message will be transformed using CXF's
transform feature and directly transferred to your camel route where you can do
further modification necessary and set the operationName header to match the
operation at the outbound endpoint </div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 12.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 10.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">In
this way, you can allow messages to be transformed using CXF transform feature
without the problem of adhering to a particular interface.</span></div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 16.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">Summary</span></div>
<div class="MsoNormal">
The transformation capabilities of the CXF transform mapping
language are limited. The transform language works well for minimal changes
such as element name changes or namespace changes. More involved e.g.
structural changes to complex types or multi-faceted elements are not easily
implemented using the mapping language.</div>
<div class="MsoNormal">
A CXF transform feature is applied to a specific CXFEndpoint
in a route. Because the transform is tightly tied to the specific CXFEndpoint,
it cannot be used to apply a transformation at random spots on a message flow
through the route. This limits the usage of the CXF transform feature as a
general mapping tool for transformations within a camel route.</div>
<div class="MsoNormal">
<span style="font-family: "Calibri","sans-serif"; font-size: 12.0pt; mso-ansi-language: EN-US; mso-bidi-font-family: "Times New Roman"; mso-bidi-font-size: 10.0pt; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">In
order to make the CXF transform feature a useful technique for performing
general transformations to messages as they flow through a route, you will
likely need to disable the opearation validation of messages at the CXFEndpoint
and use the generic provider mode. This will allow for further modifications in
the transform feature than would normally be possible if you used the default
strictly-typed message checks that typically are part of the message entry into
the route.</span></div>
lcurryhttp://www.blogger.com/profile/01568142368502338154noreply@blogger.com0tag:blogger.com,1999:blog-8028068502920625891.post-53124163288946730892014-11-11T10:42:00.001-08:002014-11-11T10:42:39.844-08:00<div class="MsoNormal">
<b><span style="font-size: 16.0pt;">Configuration model for “Environment Aware” Routes <o:p></o:p></span></b><br />
<b><span style="font-size: 16.0pt;"><br /></span></b></div>
<div class="MsoNormal">
This document will describe a configuration mechanism for
Fuse routes that will simplify deployment. No longer will you need to prompt
installer for environment, and update properties in the install script. Instead,
the configuration file (.cfg) contains property values for every environment. The route only reads
the properties associated with the environment in which the route runs. This
configuration model brings with it the following unique characteristics: </div>
<ul style="margin-top: 0in;" type="disc">
<li class="MsoNormal">Properties file contains
values of ALL properties for ALL environments. </li>
<li class="MsoNormal">Deployment no longer needs
to involve logic to set environment-specific property values.</li>
</ul>
<br />
<div class="MsoNormal">
By limiting the logic and user interaction of the deployment
script, there is less chance of making an error in the script. Also, there is a
reduction in (scripting) code that must be maintained. Environment specific
values are no longer hard-coded into the script, rather these properties have
been set up-front in static configuration (.cfg) file(s) that gets deployed
with the route(s).</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 16.0pt;">Version Info<o:p></o:p></span></b></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
This document was written based on JBoss Fuse 6.x and applies
to bundles running inside this version of the JBoss Fuse container.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 16.0pt;">Sample Property file<o:p></o:p></span></b></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
Let’s take a look at how a property file (.cfg) will look
using this model. Notice the file contains properties for every environment
(DEV, VAL, INT, PRD, etc.). Each property contains a special identifying prefix
to distinguish it as belonging to a specific environment.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<img src="file:///C:/Users/Lowry/AppData/Local/Temp/msohtmlclip1/01/clip_image002.jpg" style="font-family: Calibri, sans-serif; font-size: 12pt;" v:shapes="_x0000_i1025" /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-e05aCnnlXUw/VGJWvIdN5lI/AAAAAAAAEyo/Uuhu__eP8Wc/s1600/Untitled%2B1.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="520" src="https://1.bp.blogspot.com/-e05aCnnlXUw/VGJWvIdN5lI/AAAAAAAAEyo/Uuhu__eP8Wc/s640/Untitled%2B1.bmp" width="640" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
The above properties are written in such a way that they are
“environment aware” and only the property for the environment Fuse is running
in is picked up. The rest of the properties are ignored. Having all properties
for all environments may seem excessive, however it could be argued that having
property values for every environment available in the configuration file as a
reference is useful.</div>
<div class="MsoNormal">
<b><span style="font-size: 16.0pt;">How does Fuse know what environment it is running in?<o:p></o:p></span></b></div>
<div class="MsoNormal">
Fuse will need to be configured to “know” what environment
it is running in. You will need to do a
one-time manual edit of a specific Fuse configuration file. </div>
<div class="MsoNormal">
Inside the Fuse configuration file
‘$FUSE_INSTALL\etc\system.propeties’ you can add the following entries.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://2.bp.blogspot.com/-_PNe8v3BMCk/VGJW5oZ6niI/AAAAAAAAEyw/1_hjhDxelrM/s1600/Untitled%2B2.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="130" src="https://2.bp.blogspot.com/-_PNe8v3BMCk/VGJW5oZ6niI/AAAAAAAAEyw/1_hjhDxelrM/s640/Untitled%2B2.bmp" width="640" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
The two added entries are ‘karaf.environment’ and
‘karaf.instance’ (lines 37 and 38.) Of course, the values of these new system
properties should be appropriate for your environment and instance. You may
only have a single machine per-environment, in that case, ‘karaf.environment’ is
the only system property that needs to be defined. Add ‘karaf.instance’ if a environments have 2
or more machines, and property values may differ depending on the particular machine
(instance) within a given environment. You will need to restart Fuse in order
for these environment indicator properties to be available to your bundle’s
configuration. </div>
<div class="MsoNormal">
<span style="font-family: Calibri, sans-serif; font-size: 12pt;">Once
Fuse is restarted with the above system properties set, the following entries
added to your bundle’s configuration file will now have special meaning (see
lines 3 and 4 below).</span></div>
<div class="MsoNormal">
<span style="font-family: Calibri, sans-serif; font-size: 12pt;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-enROF5S-b-A/VGJW53QIFHI/AAAAAAAAEy0/s3NOHz4xNzY/s1600/Untitled%2B3.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="218" src="https://1.bp.blogspot.com/-enROF5S-b-A/VGJW53QIFHI/AAAAAAAAEy0/s3NOHz4xNzY/s640/Untitled%2B3.bmp" width="640" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
The configuration file specifies the values of properties by
using nested system properties to identify the environment. For example line 3
above the value of ‘to.uri’ is defined by using a nested system property
‘karaf.environment.’</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<!--[if gte vml 1]><v:shapetype id="_x0000_t87" coordsize="21600,21600"
o:spt="87" adj="1800,10800" path="m21600,qx10800@0l10800@2qy0@11,10800@3l10800@1qy21600,21600e"
filled="f">
<v:formulas>
<v:f eqn="val #0"/>
<v:f eqn="sum 21600 0 #0"/>
<v:f eqn="sum #1 0 #0"/>
<v:f eqn="sum #1 #0 0"/>
<v:f eqn="prod #0 9598 32768"/>
<v:f eqn="sum 21600 0 @4"/>
<v:f eqn="sum 21600 0 #1"/>
<v:f eqn="min #1 @6"/>
<v:f eqn="prod @7 1 2"/>
<v:f eqn="prod #0 2 1"/>
<v:f eqn="sum 21600 0 @9"/>
<v:f eqn="val #1"/>
</v:formulas>
<v:path arrowok="t" o:connecttype="custom" o:connectlocs="21600,0;0,10800;21600,21600"
textboxrect="13963,@4,21600,@5"/>
<v:handles>
<v:h position="center,#0" yrange="0,@8"/>
<v:h position="topLeft,#1" yrange="@9,@10"/>
</v:handles>
</v:shapetype><v:shape id="Left_x0020_Brace_x0020_3" o:spid="_x0000_s1026"
type="#_x0000_t87" style='position:absolute;margin-left:79.15pt;margin-top:-.3pt;
width:33pt;height:80.25pt;rotation:-90;z-index:251657728;visibility:visible;
v-text-anchor:middle' o:gfxdata="UEsDBBQABgAIAAAAIQC2gziS/gAAAOEBAAATAAAAW0NvbnRlbnRfVHlwZXNdLnhtbJSRQU7DMBBF
90jcwfIWJU67QAgl6YK0S0CoHGBkTxKLZGx5TGhvj5O2G0SRWNoz/78nu9wcxkFMGNg6quQqL6RA
0s5Y6ir5vt9lD1JwBDIwOMJKHpHlpr69KfdHjyxSmriSfYz+USnWPY7AufNIadK6MEJMx9ApD/oD
OlTrorhX2lFEilmcO2RdNtjC5xDF9pCuTyYBB5bi6bQ4syoJ3g9WQ0ymaiLzg5KdCXlKLjvcW893
SUOqXwnz5DrgnHtJTxOsQfEKIT7DmDSUCaxw7Rqn8787ZsmRM9e2VmPeBN4uqYvTtW7jvijg9N/y
JsXecLq0q+WD6m8AAAD//wMAUEsDBBQABgAIAAAAIQA4/SH/1gAAAJQBAAALAAAAX3JlbHMvLnJl
bHOkkMFqwzAMhu+DvYPRfXGawxijTi+j0GvpHsDYimMaW0Yy2fr2M4PBMnrbUb/Q94l/f/hMi1qR
JVI2sOt6UJgd+ZiDgffL8ekFlFSbvV0oo4EbChzGx4f9GRdb25HMsYhqlCwG5lrLq9biZkxWOiqY
22YiTra2kYMu1l1tQD30/bPm3wwYN0x18gb45AdQl1tp5j/sFB2T0FQ7R0nTNEV3j6o9feQzro1i
OWA14Fm+Q8a1a8+Bvu/d/dMb2JY5uiPbhG/ktn4cqGU/er3pcvwCAAD//wMAUEsDBBQABgAIAAAA
IQBOEvKSgwIAAP4EAAAOAAAAZHJzL2Uyb0RvYy54bWysVE1v2zAMvQ/YfxB0Xx1nTtsEdYq0QYYB
WRugHXpmZCk2IIuapMTpfv0o2Wm7bqdhPgj80iP5RPrq+thqdpDON2hKnp+NOJNGYNWYXcm/P64+
XXLmA5gKNBpZ8mfp+fX844erzs7kGGvUlXSMQIyfdbbkdQh2lmVe1LIFf4ZWGnIqdC0EUt0uqxx0
hN7qbDwanWcduso6FNJ7si57J58nfKWkCPdKeRmYLjnVFtLp0rmNZza/gtnOga0bMZQB/1BFC42h
pC9QSwjA9q75A6pthEOPKpwJbDNUqhEy9UDd5KN33TzUYGXqhcjx9oUm//9gxd1h41hTlbzgzEBL
T7SWKrAbB0Kyz5GfzvoZhT3YjRs0T2Js9qhcyxwSqfk5PQZ9iQPqih0Txc8vFMtjYIKMRT7NKYwJ
cuXFxXlRjGOOrAeLoNb58EViy6JQck3VpGISNBzWPvTxp7h4x+Cq0ZrsMNOGdSWfTsYTSgI0UUpD
ILG11KM3O85A72hURXAJ0aNuqng7XvZut73Vjh2AxqVYXeY3yz6ohkr21ukktplSeQjfsOrN+ehk
p1YGmNTWb/ix5iX4ur+TXEP32sT8Mk3s0GLkvWc6SlusnumlEtvEn7di1RDaGnzYgKOZJSPtYbin
Q2kkDnCQOKvR/fybPcbTKJGXs452gAj6sQcnOdNfDQ3ZNC+KuDRJKSYXY1LcW8/2rcfs21sk3vJU
XRJjfNAnUTlsn2hdFzErucAIyt0/xaDchn43aeGFXCxSGC2KhbA2D1ZE8MhT5PHx+ATODlMSaL7u
8LQvMHs3J31svGlwsQ+omjREr7zSU0WFliw92vBDiFv8Vk9Rr7+t+S8AAAD//wMAUEsDBBQABgAI
AAAAIQDgNExa3AAAAAQBAAAPAAAAZHJzL2Rvd25yZXYueG1sTI/BbsIwEETvlfgHa5F6KzaJGqE0
DoKqHCpO0Erp0cRLEmGvo9hA+PsaLu1lpdGMZt4Wy9EadsHBd44kzGcCGFLtdEeNhO+vzcsCmA+K
tDKOUMINPSzLyVOhcu2utMPLPjQslpDPlYQ2hD7n3NctWuVnrkeK3tENVoUoh4brQV1juTU8ESLj
VnUUF1rV43uL9Wl/thKa1bpKqrXZbD92t+N28Zn+VCKV8nk6rt6ABRzDXxju+BEdysh0cGfSnhkJ
8ZHwuNFL0uQV2EFClgngZcH/w5e/AAAA//8DAFBLAQItABQABgAIAAAAIQC2gziS/gAAAOEBAAAT
AAAAAAAAAAAAAAAAAAAAAABbQ29udGVudF9UeXBlc10ueG1sUEsBAi0AFAAGAAgAAAAhADj9If/W
AAAAlAEAAAsAAAAAAAAAAAAAAAAALwEAAF9yZWxzLy5yZWxzUEsBAi0AFAAGAAgAAAAhAE4S8pKD
AgAA/gQAAA4AAAAAAAAAAAAAAAAALgIAAGRycy9lMm9Eb2MueG1sUEsBAi0AFAAGAAgAAAAhAOA0
TFrcAAAABAEAAA8AAAAAAAAAAAAAAAAA3QQAAGRycy9kb3ducmV2LnhtbFBLBQYAAAAABAAEAPMA
AADmBQAAAAA=
" adj="511" strokecolor="#4a7ebb"/><![endif]--><!--[if !vml]--><span style="height: 46px; margin-left: 73px; margin-top: 30px; mso-ignore: vglayout; position: absolute; width: 109px; z-index: 251657728;"><a href="https://2.bp.blogspot.com/-XfkKOmAIixU/VGJW6F0iv2I/AAAAAAAAEy4/hiljL9Wc_IQ/s1600/Untitled%2B4.bmp" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="//2.bp.blogspot.com/-XfkKOmAIixU/VGJW6F0iv2I/AAAAAAAAEy4/hiljL9Wc_IQ/s1600/Untitled%2B4.bmp" /></a></span><!--[endif]--><span style="font-size: 14.0pt;">to.uri=${<span style="color: #00b050;">${karaf.environment}</span>.to.uri}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-size: 14.0pt;"> </span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<o:p><br /></o:p></div>
<div class="MsoNormal">
<span style="font-size: 14pt;">${<span style="color: #00b050;">DEV</span>.to.uri}</span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
The
‘${karaf.environment}’ system property (defined in the Fuse ‘system.properties’
file) will resolve at runtime to the environment name e.g. ‘DEV’, and then that
is used to designate the prefix for the property i.e. ‘${DEV.to.uri}’. This
then resolves to the correct configuration property found further down in the
configuration file (see line 7 in snippet from configuration file.) In this
example, the true value of ‘to.uri’ becomes the value of the ‘DEV’-prefixed
version of this property.</div>
<div class="MsoNormal">
Properties for all environments where the route will be
installed will be included in the configuration file. The correct prefix for
each environment will match 'karaf.environment' used for the environment and
should be specified exactly as it appears in the ‘system.properties’ file of
the container in which it appears.) For example: DEV, VAL, INT, PROD, etc.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 16.0pt;">Using the properties in the Camel Context (Spring XML
configuration)<o:p></o:p></span></b></div>
<div class="MsoNormal">
Because the use of the nested properties is confined to the
configuration file only, there is nothing special that needs to be done in the
Spring configuration for your route in order to use this configuration model.</div>
<div class="MsoNormal">
The spring configuration will refer to the normal
(non-prefixed) version of the properties. The environment-specific resolution
is confined to the property file, and
does not need to be a concern within the Spring XML of your route.</div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
See lines 27-31 where property placeholders are used as
values of properties injected into a Spring bean. See line 37 where the value
of a property placeholder is used within the camel route. (Notice the need for double
brackets ‘{{‘ and ‘}}’ to de-reference such properties from within the camel
route. )</div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-9ZTdAR9kWlE/VGJYIk6ep5I/AAAAAAAAEzM/xwTlim41uOo/s1600/New%2BBitmap%2BImage%2B5.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="412" src="https://1.bp.blogspot.com/-9ZTdAR9kWlE/VGJYIk6ep5I/AAAAAAAAEzM/xwTlim41uOo/s640/New%2BBitmap%2BImage%2B5.bmp" width="640" /></a></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
In summary, the use of env-specific properties within your
configuration will not affect your route’s code. </div>
<div class="MsoNormal">
<br /></div>
lcurryhttp://www.blogger.com/profile/01568142368502338154noreply@blogger.com0tag:blogger.com,1999:blog-8028068502920625891.post-50163622706896327282014-09-29T10:39:00.000-07:002014-09-29T10:39:07.243-07:00How do I configure Red Hat JBoss Fuse to send an Email when specific logging event occurs?
<span style="font-family: Calibri;">In the post I will describe how to configure Fuse ESB to
automatically send emails when certain logging events occur. This technique
uses Log4j’s SMTPAppender. <o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt;">
<span style="font-family: Calibri;">Log4j can be configured to push email notification
immediately when an ERROR occurs inside the ESB. <o:p></o:p></span></div>
<span style="font-family: Calibri;">The configuration of the SMTPAppender within Fuse is not
particularly straight forward. There are some gotchas that I have attempted to
point out here. Perhaps future versions of Fuse will make it easier to
configure this.<o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt;">
<span style="font-family: Calibri;">These instructions are written based on Fuse version
6.0.0.redhat-024 available for download in platform independent form here
(download zip file):<o:p></o:p></span></div>
h<a href="http://repo.fusesource.com/nexus/content/groups/public/org/jboss/fuse/jboss-fuse/6.0.0.redhat-024/"><span style="color: blue; font-family: Calibri;">ttp://repo.fusesource.com/nexus/content/groups/public/org/jboss/fuse/jboss-fuse/6.0.0.redhat-024/</span></a><o:p></o:p><br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt;">
<span style="font-family: Calibri;">Or, assuming you have maven installed, the following command
will download the installation .zip file, and put the file into your local
maven repository:<o:p></o:p></span></div>
<span style="font-family: "Courier New";">mvn
org.apache.maven.plugins:maven-dependency-plugin:2.8:get
-Dartifact=org.jboss.fuse:jboss-fuse:6.0.0.redhat-024:zip<o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt;">
<span style="font-family: Calibri;">Some of the complications with getting this to work are reported
in the following bug report:<o:p></o:p></span></div>
<a href="https://issues.apache.org/jira/i#browse/KARAF-3067"><span style="color: blue; font-family: Calibri;">https://issues.apache.org/jira/i#browse/KARAF-3067</span></a><o:p></o:p><br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt;">
<span style="font-family: Calibri;">My research indicates that you must apply the configuration
to a “fresh” installation of Fuse. If you have an existing installation of
Fuse, you must clear the bundle cache (i.e. completely remove the ‘data’
directory), then make the necessary configuration changes before starting Fuse
for the first time. This is annoying if you have an existing installation and
merely wish to add the feature to an existing installation. <o:p></o:p></span></div>
<span style="font-family: Calibri;">Here are the steps I took to enable SMTPAppender on a fresh
install of Fuse. Before starting Fuse for the first time, I applied the
following steps:<o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span style="mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-family: Calibri;">1)</span><span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";">
</span></span></span><span style="font-family: Calibri;">Added configuration for the SMTP Appender (as shown
below) into [jboss-fuse-6.0]/etc /org.ops4j.pax.logging.cfg. Be sure to back up
the file first. See updated configuration below:<o:p></o:p></span></div>
<span style="font-family: "Courier New";">#
Root logger<o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">log4j.rootLogger=INFO,
out, osgi:VmLogAppender, mail<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">…<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">…<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">#
SMTP appender<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">log4j.appender.mail=org.apache.log4j.net.SMTPAppender<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">log4j.appender.mail.layout=org.apache.log4j.PatternLayout<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">log4j.appender.mail.layout.ConversionPattern=%d
[%t] %-5p %c %x - %m%n<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">log4j.appender.mail.SMTPPort=25<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">log4j.appender.mail.SMTPProtocol=smtp<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">log4j.appender.mail.Subject=JBoss
Fuse 6.0 Error Log Message<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">log4j.appender.mail.SendOnClose=false<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">log4j.appender.mail.SMTPHost
= mailrelay.mycompany.com<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">log4j.appender.mail.From=username@host1.mycompany.com<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">log4j.appender.mail.To=lcurry@mycompany.com<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">#log4j.appender.mail.Threshold=INFO<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">log4j.appender.mail.SMTPDebug=true<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">#log4j.appender.mail.SMTPPassword=********<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">#log4j.appender.mail.SMTPUsername=user@gmail.com<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">log4j.appender.mail.BufferSize=512<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span style="mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-family: Calibri;">2)</span><span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";">
</span></span></span><span style="font-family: Calibri;">In the <span style="mso-spacerun: yes;"> </span>[jboss-fuse-6.0]/etc/jre.properties file I needed
to comment out the javax.activation;version="1.1".<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt 0.5in;">
<span style="font-family: Calibri;">This ‘jre.properties’ file allow
you to define in Fuse ESB which packages should be provided by the JRE and
which can be provided by application bundles. To customize this you can tune
the ‘jre.properties’ file. So, you can update this file to prevent JRE’s
package ‘javax.activation’ from being exported. <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt 0.5in;">
<span style="font-family: Calibri;">Again make a backup of ‘jre.properties’
before modifying.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt 0.5in;">
<span style="font-family: Calibri;">Now modify the file as indicated
below: Note there are two occurences of ‘javax.activation’ (for JRE 1.6 and
1.7) and you should comment out both. <o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">#
Standard package set.<span style="mso-spacerun: yes;"> </span>Note that:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">#<span style="mso-spacerun: yes;"> </span>- javax.transaction* is exported with a mandatory
attribute<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">jre-1.6=
\<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";"><span style="mso-spacerun: yes;"> </span>javax.accessibility, \<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">#
javax.activation;version="1.1", \<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";"><span style="mso-spacerun: yes;"> </span>javax.activity, \<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";"><span style="mso-spacerun: yes;"> </span>javax.annotation;version="1.1", \<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";"><span style="mso-spacerun: yes;"> </span>javax.annotation.processing;version="1.1",
\<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";"><span style="mso-spacerun: yes;"> </span>javax.crypto, \<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";"><span style="mso-spacerun: yes;"> </span>javax.crypto.interfaces, \<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";"><span style="mso-spacerun: yes;"> </span>javax.crypto.spec, \<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">…<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">…<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">#
Standard package set.<span style="mso-spacerun: yes;"> </span>Note that:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">#<span style="mso-spacerun: yes;"> </span>- javax.transaction* is exported with a
mandatory attribute<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">jre-1.7=
\<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";"><span style="mso-spacerun: yes;"> </span>javax.accessibility, \<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";">#
javax.activation;version="1.1", \<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";"><span style="mso-spacerun: yes;"> </span>javax.activity, \<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";"><span style="mso-spacerun: yes;"> </span>javax.annotation;version="1.1", \<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";"><span style="mso-spacerun: yes;"> </span>javax.annotation.processing;version="1.1",
\<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";"><span style="mso-spacerun: yes;"> </span>javax.crypto, \<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";"><span style="mso-spacerun: yes;"> </span>javax.crypto.interfaces, \<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";"><span style="mso-spacerun: yes;"> </span>javax.crypto.spec, \<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Courier New";"><span style="mso-spacerun: yes;"> </span>javax.imageio, \<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span style="mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-family: Calibri;">3)</span><span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";">
</span></span></span><span style="font-family: Calibri;">Because (previous step) will block the JRE’s
version of the package ‘javax.activation’ from being exported, we can force a
different version of this package to be used by Fuse. <span style="mso-spacerun: yes;"> </span>To do this, copy the following JAR to
[jboss-fuse-6.0]/lib/endorsed<o:p></o:p></span></div>
<span style="font-family: Calibri;"><span style="mso-spacerun: yes;">
</span>org.apache.servicemix.specs.activation-api-1.1-2.0.0.redhat-60024.jar<o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt;">
<span style="font-family: Calibri;">You can retrieve the JAR file from the following public
maven repository:<o:p></o:p></span></div>
<a href="http://repo.fusesource.com/nexus/content/groups/public/org/apache/servicemix/specs/org.apache.servicemix.specs.activation-api-1.1/2.0.0.redhat-60024/"><span style="color: blue; font-family: Calibri;">http://repo.fusesource.com/nexus/content/groups/public/org/apache/servicemix/specs/org.apache.servicemix.specs.activation-api-1.1/2.0.0.redhat-60024/</span></a><o:p></o:p><br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt;">
<span style="font-family: Calibri;">Or, assuming you have maven installed, the following command
will download the JAR file into your local maven repository:<o:p></o:p></span></div>
<span style="font-family: "Courier New";">mvn
org.apache.maven.plugins:maven-dependency-plugin:2.8:get
-Dartifact=org.apache.servicemix.specs:org.apache.servicemix.specs.activation-api-1.1:2.0.0.redhat-60024<o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt;">
<span style="font-family: Calibri;">Note:<span style="mso-spacerun: yes;"> </span>The
org.apache.servicemix.specs.activator-2.0.0.redhat-60024.jar should be in the
[jboss-fuse-6.0]/lib directory, and should already be there by default.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span style="mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-family: Calibri;">4)</span><span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";">
</span></span></span><span style="font-family: Calibri;">The Log4J SMTPAppender requires a mail bundle be
deployed into Fuse. Therefore we must add a mail bundle to Fuse. The
recommended way to do this is to configure Fuse so that the bundle is deployed
on start-up. Define your own custom feature with a start level low enough to
take precendence. I picked up this trick up from KARAF-3067.<span style="mso-spacerun: yes;"> </span>This ensure supported version of javax.mail
API is installed and used.<span style="mso-spacerun: yes;"> </span><o:p></o:p></span></div>
<span style="font-family: Calibri;">I created a feature called
‘javax.mail’.<span style="mso-spacerun: yes;"> </span>The feature descriptor is
called ‘javax.mail-1.0.0.redhat-60024-features.xml.’ <o:p></o:p></span><br />
<span style="font-family: "Courier New";"></span><br />
<span style="font-family: "Courier New";"><features><o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New";"><feature name="javax.mail"
version="1.4.5"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New";"><span style="mso-spacerun: yes;">
</span><bundle
start-level="7">mvn:javax.mail/mail/1.4.5</bundle><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New";"></feature><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New";"></features><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: Calibri;">Copy above feature descriptor to a location where Fuse can
find it. Create a directory ‘local-repo’ in the root installation folder. Fuse
will look there by default for maven dependencies. The complete path to the
location where I copied the descriptor was as follows: [jboss-fuse-6.0]/
local-repo/com/mycompany/features/javax.mail/1.0.0.redhat-60024<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt;">
<span style="font-family: Calibri;">The name of the feature descriptor file in that directory
was:<o:p></o:p></span></div>
<span style="font-family: Calibri;">javax.mail-1.0.0.redhat-60024-features.xml<o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt;">
<span style="font-family: Calibri;">Remember, the actual name of the feature descriptor file and
the location where it is copied matter (a lot). The location must match the
standard well-known maven directory location based on
groupId/artifactId/version coordinates.<o:p></o:p></span></div>
<span style="mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-family: Calibri;">5)</span><span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";">
</span></span></span><span style="font-family: Calibri;">Add the custom feature ‘javax.mail’ to the set
of features that Fuse installs at startup. <o:p></o:p></span><br />
<span style="font-family: Calibri;">So once I have the feature
descriptor file in the correct location where Fuse can find it, I will add the
feature to the list of features that get installed at Fuse startup. To do this
add the feature to the file ‘[jboss-fuse-6.0]/etc/org.apache.karaf.features.cfg’
.<span style="mso-spacerun: yes;"> </span>Make a backup of this file, and below
shows the necessary additions to this file.<o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 10pt;">#<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"># Comma separated list of
features repositories to register by default<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 10pt;">#<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 10pt;">featuresRepositories=\<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span>mvn:org.apache.karaf.assemblies.features/standard/2.3.0.redhat-60024/xml/features,\<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"><span style="mso-spacerun: yes;">
</span>mvn:org.apache.karaf.assemblies.features/enterprise/2.3.0.redhat-60024/xml/features,\<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"><span style="mso-spacerun: yes;">
</span>mvn:org.apache.cxf.karaf/apache-cxf/2.6.0.redhat-60024/xml/features,\<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"><span style="mso-spacerun: yes;">
</span>mvn:org.apache.camel.karaf/apache-camel/2.10.0.redhat-60024/xml/features,\<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"><span style="mso-spacerun: yes;">
</span>mvn:org.apache.activemq/activemq-karaf/5.8.0.redhat-60024/xml/features,\<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"><span style="mso-spacerun: yes;">
</span>mvn:org.apache.servicemix.nmr/apache-servicemix-nmr/1.6.0.redhat-60024/xml/features,\<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"><span style="mso-spacerun: yes;">
</span>mvn:org.fusesource.fabric/fuse-fabric/7.2.0.redhat-024/xml/features,\<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"><span style="mso-spacerun: yes;">
</span>mvn:org.jboss.fuse/jboss-fuse/6.0.0.redhat-024/xml/features,\<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"><span style="mso-spacerun: yes;">
</span>mvn:org.fusesource.patch/patch-features/7.2.0.redhat-024/xml/features,\<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span>mvn:com.mycompany.features/javax.mail/1.0.0.redhat-60024/xml/features<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
</div>
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 10pt;">#<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"># Comma separated list of
features to install at startup<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 10pt;">#<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 10pt;">featuresBoot=javax.mail,jasypt-encryption,config,management,fabric-boot-commands,fabric-bundle,fabric-maven-proxy,patch,activemq,mq-fabric,camel,camel-cxf,camel-jms,activemq-camel,camel-blueprint,camel-</span><span style="font-family: "Courier New"; font-size: 10pt;">csv,camel-ftp,camel-bindy,camel-jdbc,camel-exec,camel-jasypt,camel-saxon,camel-snmp,camel-ognl,camel-routebox,camel-script,camel-spring-javaconfig,camel-jaxb,camel-jetty,camel-jmx,camel-mail,camel-paxlo</span><span style="font-family: "Courier New"; font-size: 10pt;">gging,camel-rmi,war<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt;">
<span style="font-family: Calibri;">Note the addition of the feature URL in the
‘featuresRepositories’ property and also the additional feature ‘javax.mail’
added to the front of the ‘featuresBoot’ list.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span style="mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-family: Calibri;">6)</span><span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";">
</span></span></span><span style="font-family: Calibri;">Finally, after configuring everything - <span style="mso-spacerun: yes;"> </span>I start Fuse. The first time I start Fuse
after making the configuration changes described above, I got an ERROR that
looked something like this:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 8pt;">14:25:46,185 | ERROR |
s4j.pax.logging) | configadmin<span style="mso-spacerun: yes;"> </span>| 5 -
org.apache.felix.configadm<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 8pt;">in - 1.4.0.redhat-60024 |
[org.osgi.service.log.LogService, org.knopflerfish.service.log.LogService,
org.op<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 8pt;">s4j.pax.logging.PaxLoggingService,
org.osgi.service.cm.ManagedService, id=9, bundle=3/mvn:org.ops4j.pax.log<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 8pt;">ging/pax-logging-service/1.7.0]:
Unexpected problem updating configuration org.ops4j.pax.logging<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 8pt;">java.lang.NoClassDefFoundError:
javax/mail/MessagingException<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 8pt;"><span style="mso-spacerun: yes;"> </span>at
java.lang.Class.getDeclaredConstructors0(Native Method)<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 8pt;"><span style="mso-spacerun: yes;"> </span>at
java.lang.Class.privateGetDeclaredConstructors(Class.java:2532)<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 8pt;"><span style="mso-spacerun: yes;"> </span>at java.lang.Class.getConstructor0(Class.java:2842)<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 8pt;"><span style="mso-spacerun: yes;"> </span>at
java.lang.Class.newInstance(Class.java:345)<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 8pt;"><span style="mso-spacerun: yes;"> </span>at
org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:336)<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 8pt;"><span style="mso-spacerun: yes;"> </span>at
org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 8pt;"><span style="mso-spacerun: yes;"> </span>at
org.apache.log4j.PaxLoggingConfigurator.parseAppender(PaxLoggingConfigurator.java:97)<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 8pt;"><span style="mso-spacerun: yes;"> </span>at
org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:735)<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 8pt;"><span style="mso-spacerun: yes;"> </span>at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:615)<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 8pt;"><span style="mso-spacerun: yes;"> </span>at
org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:502)<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 8pt;"><span style="mso-spacerun: yes;"> </span>at
org.apache.log4j.PaxLoggingConfigurator.doConfigure(PaxLoggingConfigurator.java:72)<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 8pt;"><span style="mso-spacerun: yes;"> </span>at
org.ops4j.pax.logging.service.internal.PaxLoggingServiceImpl.updated PaxLoggingServiceImpl.java:<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 0pt;">
<span style="font-family: "Courier New"; font-size: 8pt;">214)<o:p></o:p></span></div>
<br />
<span style="font-family: Calibri;">I had to shut down and restart Fuse. The second start seemed
to do the trick. At that point I can see the debug logging for SMTP (only from
the Fuse console.) If the container is properly configured, and when you start
Fuse (the second time) you will see some logging at the Fuse console that
indicates the SMTPAppender is operational (per setting<span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span>log4j.appender.mail.SMTPDebug=true):<o:p></o:p></span><br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt;">
<span style="font-family: Calibri;">Note: I only saw debug output for log4j SMTP (based on <span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span>log4j.appender.mail.SMTPDebug=true) only if I
started Fuse in foreground using './fuse' rather than starting Fuse in
background with './start'.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span style="mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-family: Calibri;">7)</span><span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";">
</span></span></span><span style="font-family: Calibri;">To test the email notification, deliberately cause
an error in Fuse. For example, you could bogus spring file into the deploy
directory (purposely include invalid XML so that the ESB gets an ERROR.)<span style="mso-spacerun: yes;"> </span>You should see debug in the Fuse console
indicating an email being sent. Or you may see an error of some sort indicating
further configuration required for SMTP to work properly.<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 12pt;">
<span style="font-family: Calibri;"><span style="mso-spacerun: yes;"> </span><o:p></o:p></span></div>
lcurryhttp://www.blogger.com/profile/01568142368502338154noreply@blogger.com0tag:blogger.com,1999:blog-8028068502920625891.post-77615785396884085282012-04-12T04:38:00.000-07:002012-04-12T04:38:21.190-07:00Using Chainsaw to view Servicemix logs<span style="font-family: Calibri;">Chainsaw is an open-source GUI-based log viewer. If you’ve
ever wanted to utilize chainsaw to view Servicemix log file then this post is
for you!</span><br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">I use FuseSource distribution of Servicemix (aka Fuse ESB.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">You can download Fuse ESB here:</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<a href="http://fusesource.com/downloads/"><span style="color: blue; font-family: Calibri;">http://fusesource.com/downloads/</span></a></div>
<span style="font-family: Calibri;">I was able to visualize the Servicemix logs inside the
Chainsaw GUI using the following steps:</span><br />
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span style="mso-bidi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-family: Calibri;">1)</span><span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";"> </span></span></span><span style="font-family: Calibri;">Install
Chainsaw.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">Download the latest distribution of chainsaw.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<a href="http://logging.apache.org/chainsaw/download.html"><span style="color: blue; font-family: Calibri;">http://logging.apache.org/chainsaw/download.html</span></a></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">I downloaded the “Unix/Dos standalone version”</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">Extract to location of choice.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span style="mso-bidi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-family: Calibri;">2)</span><span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";"> </span></span></span><span style="font-family: Calibri;">Configure
Chainsaw to listen for logging events on a given port. </span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">Into the directory where I extracted chainsaw, I created a
file “chainsaw-config.xml” with the following contents.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: "Courier New", Courier, monospace;"><?xml version="1.0" encoding="UTF-8"
?></span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: "Courier New", Courier, monospace;"><!DOCTYPE log4j:configuration ></span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: "Courier New", Courier, monospace;"><log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="true"></span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: "Courier New", Courier, monospace;"><span style="mso-spacerun: yes;"> </span><plugin
name="SocketReceiver" </span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: "Courier New", Courier, monospace;">class="org.apache.log4j.net.SocketReceiver"></span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: "Courier New", Courier, monospace;"><span style="mso-spacerun: yes;"> </span><param
name="Port" value="4445"/></span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: "Courier New", Courier, monospace;"><span style="mso-spacerun: yes;"> </span></plugin></span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: "Courier New", Courier, monospace;"><span style="mso-spacerun: yes;"> </span><root></span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: "Courier New", Courier, monospace;"><span style="mso-spacerun: yes;"> </span><level
value="debug"/></span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: "Courier New", Courier, monospace;"><span style="mso-spacerun: yes;"> </span></root></span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: "Courier New", Courier, monospace;"></log4j:configuration></span></div>
<span style="font-family: "Courier New", Courier, monospace;">
</span><br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">The above configures chainsaw with a SocketReceiver that
will listen on port 4445 to receive logging events. </span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span style="mso-bidi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-family: Calibri;">3)</span><span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";"> </span></span></span><span style="font-family: Calibri;">Configure
Servicemix to send logging events.</span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.25in;">
<span style="font-family: Calibri;">Now to configure Servicemix to
send logging event to this port you will update the Servicemix configuration.
Edit the config file ‘org.ops4j.pax.logging.cfg’. Use the following as a guide
for editing this file:</span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.25in;">
<span style="font-family: "Courier New", Courier, monospace;"># the below line is an ‘edit’ of
exising line – added a Chainsaw appender</span></div>
<span style="font-family: "Courier New", Courier, monospace;">
</span><br />
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.25in;">
<span style="font-family: "Courier New", Courier, monospace;">log4j.rootLogger = INFO, sift,
Chainsaw, osgi:VmLogAppender</span></div>
<span style="font-family: "Courier New", Courier, monospace;">
</span><br />
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.25in;">
<span style="font-family: "Courier New", Courier, monospace;">…</span></div>
<span style="font-family: "Courier New", Courier, monospace;">
</span><br />
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.25in;">
<span style="font-family: "Courier New", Courier, monospace;"># the below are completely new
lines to configure the Chainsaw appender</span></div>
<span style="font-family: "Courier New", Courier, monospace;">
</span><br />
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.25in;">
<span style="font-family: "Courier New", Courier, monospace;">log4j.appender.Chainsaw =
org.apache.log4j.net.SocketAppender</span></div>
<span style="font-family: "Courier New", Courier, monospace;">
</span><br />
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.25in;">
<span style="font-family: "Courier New", Courier, monospace;">log4j.appender.Chainsaw.remoteHost
= localhost</span></div>
<span style="font-family: "Courier New", Courier, monospace;">
</span><br />
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.25in;">
<span style="font-family: "Courier New", Courier, monospace;">log4j.appender.Chainsaw.port =
4560</span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.25in;">
<span style="font-family: Calibri;">Make sure the “remoteHost” is the
IP for the machine where you are running Chainsaw (or localhost) if you plan to
run Chainsaw GUI on same box as Servicemix. Once you save this file the changes
will take effect immediately, should be no need to restart Servicemix.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.25in;">
<span style="font-family: Calibri;">You may see Servicemix complain
about not being able to find a receiver for its events. That’s because you
don’t have Chainsaw up yet. Don’t worry Servicemix will retry again once you
stand up the Chainsaw GUI.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span style="mso-bidi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-family: Calibri;">4)</span><span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";"> </span></span></span><span style="font-family: Calibri;">Bring
up Chainsaw</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.25in;">
<span style="font-family: Calibri;">From the directory where you
installed chainsaw, run the file ‘chainsaw.bat’.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.25in;">
<span style="font-family: Calibri;">When you start first time it will
give you a warning about not having Receivers defined. You can select “Let me
use a simple Receiver:” and select “SocketReceiver” on port “4560 (Default
SocketAppender port.)”</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span style="mso-bidi-font-family: Calibri;"><span style="mso-list: Ignore;"><span style="font-family: Calibri;">5)</span><span style="font-size-adjust: none; font-stretch: normal; font: 7pt/normal "Times New Roman";"> </span></span></span><span style="font-family: Calibri;">View
the logs in Chainsaw</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.5in;">
<span style="font-family: Calibri;">Since we are experimenting, you may
want to turn up the logs in Servicemix to prove all the logs are reaching
Chainsaw.</span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.5in;">
<span style="font-family: Calibri;">From the Servicemix console type:</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.5in;">
<span style="font-family: "Courier New", Courier, monospace;">log:set DEBUG root</span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.5in;">
<span style="font-family: Calibri;">This will turn up the logging to
highest level.</span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.25in;">
<span style="font-family: Calibri;">Once Servicemix sends an event. You
will eventually see a tab pop up in Chainsaw that contains the logs it receives
from the Servicemix instance. You should see quite a bit of logging being
displayed in Chainsaw.</span></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-CAaQ15EE4vA/T4a-PSFi8DI/AAAAAAAACZY/gO3kd7jU22g/s1600/chainsaw.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="248" src="http://3.bp.blogspot.com/-CAaQ15EE4vA/T4a-PSFi8DI/AAAAAAAACZY/gO3kd7jU22g/s320/chainsaw.jpg" width="320" /></a></div>
<br />
<br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.25in;">
<span style="mso-no-proof: yes;"><v:shapetype coordsize="21600,21600" filled="f" id="_x0000_t75" o:preferrelative="t" o:spt="75" path="m@4@5l@4@11@9@11@9@5xe" stroked="f"><span style="font-family: Calibri;">
<v:stroke joinstyle="miter">
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0">
<v:f eqn="sum @0 1 0">
<v:f eqn="sum 0 0 @1">
<v:f eqn="prod @2 1 2">
<v:f eqn="prod @3 21600 pixelWidth">
<v:f eqn="prod @3 21600 pixelHeight">
<v:f eqn="sum @0 0 1">
<v:f eqn="prod @6 1 2">
<v:f eqn="prod @7 21600 pixelWidth">
<v:f eqn="sum @8 21600 0">
<v:f eqn="prod @7 21600 pixelHeight">
<v:f eqn="sum @10 21600 0">
</v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:formulas>
</v:stroke></span></v:shapetype></span><span style="font-family: Calibri;">To turn off the excessive logging
in Servicemix and return Servicmix to the default logging level, from the
Servicemix console type:</span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.25in;">
<span style="font-family: "Courier New", Courier, monospace;">log:set INFO root</span></div>
<br />
I'm not totally convinced yet whether this will be a useful capability. I'm open to suggestions on how this might be used, or whether people are using this sort of thing at all. I'm a little disappointed in the overall model, that is Servicemix must be configured to send logs to Chainsaw. <br />
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.25in;">
<br /></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt 0.25in;">
<br /></div>lcurryhttp://www.blogger.com/profile/01568142368502338154noreply@blogger.com1tag:blogger.com,1999:blog-8028068502920625891.post-89579255395630205942012-03-12T12:03:00.003-07:002012-03-16T05:31:31.451-07:00A Generic Pass-Through Route to solve a variety of Integration Challenges<span style="font-family: Calibri;">Have you have ever needed to write a proxy (pass-through) route? This scenario applies to situations where you receive an HTTP request from a client, and simply need to redirect that HTTP request to another back-end server, returning the response from back end to the original client.</span><br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">You might want to add some custom processing<span style="mso-spacerun: yes;"> </span>or transformation to the message (or not) before sending to the back end service. Camel makes it easy to add such custom processing. I’ve seen cases where the simple ability to log and provide a “point of record” was enough to warrant the use of a pass-through route.<span style="mso-spacerun: yes;"> </span>Another use for a pass-through would be to “fix” a request message<span style="mso-spacerun: yes;"> </span>(so that it contains expected payload) before sending it on to the server – or manipulating a response into a suitable format for the client. <span style="mso-spacerun: yes;"> </span>You can imagine a pass-through route that doesn’t touch requests coming from newer clients, but that can update requests (on the fly) that come from legacy clients so that those messages adhere to newer version, and eliminate need to maintain older back end server.<span style="mso-spacerun: yes;"> </span></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">So now that we’ve established the usefulness of a pass-through pattern – I will show you an easy way to implement this pattern. Apache Camel makes it very easy to write a route that implements the pass-through pattern.</span><span style="font-family: "Courier New"; font-size: 8pt; line-height: 115%;"> </span><span style="font-family: Calibri;">Here I will descried the steps of to create such a pass-through route is just a matter of minutes. You can create a new FUSE Project using the <a href="http://fusesource.com/products/fuse-ide/">FUSE IDE</a>. You can download FUSE IDE from here:</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<a href="http://fusesource.com/products/fuse-ide/">http://fusesource.com/products/fuse-ide/</a></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">Once installed, FUSE IDE will allow you to easily create any type of route.</span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">Below is the spring configuration that implements the proxy route. </span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<br /></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: teal; font-family: "Courier New"; font-size: 8pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 8pt;">beans</span><span style="font-family: "Courier New"; font-size: 8pt;"> <span style="color: #7f007f;">xmlns</span><span style="color: black;">=</span><i><span style="color: #2a00ff;">"http://www.springframework.org/schema/beans"</span></i></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Courier New"; font-size: 8pt;"><span style="mso-tab-count: 1;"> </span><span style="color: #7f007f;">xmlns:camel</span><span style="color: black;">=</span><i><span style="color: #2a00ff;">"http://camel.apache.org/schema/spring"</span></i> <span style="color: #7f007f;">xmlns:xsi</span><span style="color: black;">=</span><i><span style="color: #2a00ff;">"http://www.w3.org/2001/XMLSchema-instance"</span></i></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Courier New"; font-size: 8pt;"><span style="mso-tab-count: 1;"> </span><span style="color: #7f007f;">xsi:schemaLocation</span><span style="color: black;">=</span><i><span style="color: #2a00ff;">"<span style="mso-spacerun: yes;"> </span>http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd<span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span>http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"</span></i><span style="color: teal;">></span></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: black; font-family: "Courier New"; font-size: 8pt;"><span style="mso-tab-count: 1;"> </span></span><span style="color: teal; font-family: "Courier New"; font-size: 8pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 8pt;">camelContext</span><span style="font-family: "Courier New"; font-size: 8pt;"> <span style="color: #7f007f;">xmlns</span><span style="color: black;">=</span><i><span style="color: #2a00ff;">"http://camel.apache.org/schema/spring"</span></i><span style="color: teal;">></span></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: black; font-family: "Courier New"; font-size: 8pt;"><span style="mso-tab-count: 2;"> </span></span><span style="color: teal; font-family: "Courier New"; font-size: 8pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 8pt;">route</span><span style="color: teal; font-family: "Courier New"; font-size: 8pt;">></span><span style="font-family: "Courier New"; font-size: 8pt;"></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: black; font-family: "Courier New"; font-size: 8pt;"><span style="mso-tab-count: 3;"> </span></span><span style="color: teal; font-family: "Courier New"; font-size: 8pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 8pt;">from</span><span style="font-family: "Courier New"; font-size: 8pt;"> <span style="color: #7f007f;">uri</span><span style="color: black;">=</span><i><span style="color: #2a00ff;">"jetty:http://0.0.0.0:5012/proxy/incoming"</span></i> <span style="color: teal;">/></span></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: black; font-family: "Courier New"; font-size: 8pt;"><span style="mso-tab-count: 3;"> </span></span><span style="color: teal; font-family: "Courier New"; font-size: 8pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 8pt;">to</span><span style="font-family: "Courier New"; font-size: 8pt;"> <span style="color: #7f007f;">uri</span><span style="color: black;">=</span><i><span style="color: #2a00ff;">"log:com.fusesource.proxytest?level=DEBUG&amp;showAll=true&amp;multiline=true&amp;showBody=true"</span></i> <span style="color: teal;">/></span></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: teal; font-family: "Courier New"; font-size: 8pt;"><span style="mso-tab-count: 3;"> </span><removeHeaders pattern="CamelHttp*"/></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: teal; font-family: "Courier New"; font-size: 8pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 2;"> </span><removeHeader headerName="Host"/></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: teal; font-family: "Courier New"; font-size: 8pt;"><span style="mso-spacerun: yes;"> </span></span><span style="font-family: "Courier New"; font-size: 8pt;"></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: black; font-family: "Courier New"; font-size: 8pt;"><span style="mso-tab-count: 3;"> </span></span><span style="color: teal; font-family: "Courier New"; font-size: 8pt;"><</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 8pt;">to</span><span style="font-family: "Courier New"; font-size: 8pt;"> <span style="color: #7f007f;">uri</span><span style="color: black;">=</span><i><span style="color: #2a00ff;">"jetty:http://localhostt:3000/myservice/send"</span></i> <span style="color: teal;">/></span></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: black; font-family: "Courier New"; font-size: 8pt;"><span style="mso-tab-count: 2;"> </span></span><span style="color: teal; font-family: "Courier New"; font-size: 8pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 8pt;">route</span><span style="color: teal; font-family: "Courier New"; font-size: 8pt;">></span><span style="font-family: "Courier New"; font-size: 8pt;"></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: black; font-family: "Courier New"; font-size: 8pt;"><span style="mso-tab-count: 1;"> </span></span><span style="color: teal; font-family: "Courier New"; font-size: 8pt;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 8pt;">camelContext</span><span style="color: teal; font-family: "Courier New"; font-size: 8pt;">></span><span style="font-family: "Courier New"; font-size: 8pt;"></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="color: teal; font-family: "Courier New"; font-size: 8pt; line-height: 115%;"></</span><span style="color: #3f7f7f; font-family: "Courier New"; font-size: 8pt; line-height: 115%;">beans</span><span style="color: teal; font-family: "Courier New"; font-size: 8pt; line-height: 115%;">></span><span style="font-family: "Courier New"; font-size: 8pt; line-height: 115%;"></span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">From the example, you can see the incoming component is the camel jetty. The Outgoing is also camel jetty.</span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">The reason for the “removeHeaders” is basically to remove all the CamelHttp* headers that get populated by the incoming camel jetty consumer. Because certain headers get automatically populated and retained as the exchange passes through the route, the existence of these headers could potentially confuse and impact the behavior of the outgoing camel jetty producer. When certain headers are not removed, The outgoing jetty producer component (that sends requests to back end) gets confused, potentially over-riding the value configured for destination URL, <span style="mso-spacerun: yes;"> </span>and you can end up with unexpected value for actual endpoint destination URL used by consumer component. Take care with these CamelHttp* headers and my advice is remove them in routes that go from jetty consumer to <span style="mso-spacerun: yes;"> </span>jetty producer. <span style="mso-spacerun: yes;"> </span>The basic idea is explained here:</span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<a href="http://camel.apache.org/how-to-remove-the-http-protocol-headers-in-the-camel-message.html"><span style="color: blue; font-family: Calibri;">http://camel.apache.org/how-to-remove-the-http-protocol-headers-in-the-camel-message.html</span></a></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">You may be tempted to use the Camel HTTP component (camel-http) rather than 'jetty' for calling the back end in your pass-through route. The 'jetty' producer component has better performance under load, so it is almost always the right choice for this pattern.</span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">The Jetty HTTP client endpoint uses the Jetty library to implement a HTTP client. In particular, the Jetty HTTP client features support for HttpClient thread pool and non-blocking request/response.<span style="mso-spacerun: yes;"> </span>See more info on benefits of the Camel 'jetty' producer component in <a href="http://fusesource.com/docs/router/2.8/camel_cxf/Proxying-HTTP.html">the FUSE documentation for writing a pass-through route</a> .</span></div>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">I’m attaching a working example. If you want to play with working code - <a href="http://dl.dropbox.com/u/9504051/proxy_test.zip">you can download it from here.</a> </span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">The the following sub-projects:</span></div>
<span style="font-family: Calibri;"><strong>proxytest -</strong> A maven project that implements the route. To build run 'mvn install'. To run the route in standalone mode you can type 'mvn camel:run'.</span><br />
<br />
<span style="font-family: Calibri;"><strong>mockservice</strong> - A simple mock server that mimics a real back end service. Your pass-through route can use this to redirect requests to in the absence of a real back end service. To build type 'mvn install'. To run the mock service in standalone mode you can type 'mvn camel:run'.</span><br />
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">Included, is a sample SOAP UI client project (see proxytest\proxy-test-soapui-project.xml) that you can import into SOAP UI, and use to send HTTP request into the route. The route will receive the request on port 5012, redirect to the mock service listening on port 3000. The mock service will simply echo back the request. The route will then return the response back to the original SOAP UI client. <span style="mso-spacerun: yes;"> </span>You can use SOAP UI to perform load tests on your new proxy service!</span></div>lcurryhttp://www.blogger.com/profile/01568142368502338154noreply@blogger.com0tag:blogger.com,1999:blog-8028068502920625891.post-51800220726418798642011-06-29T18:26:00.000-07:002017-09-11T17:21:46.088-07:00Camel Integration with Oracle WebLogic JMS<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">This post is similar to a previous post <a href="http://lowry-techie.blogspot.com/2010/11/camel-integration-with-websphere-mq.html">Camel Integration with WebSphere MQ</a>. However, this time I will describe my experience with implementing a Camel route that integrates with WebLogic JMS. The Camel route runs inside Servicemix as an OSGI bundle. I used the Enterprise version of Servicemix from FuseSource available here:<br />
<a href="http://fusesource.com/downloads/"><span style="color: #2288bb;">http://fusesource.com/downloads/</span></a><br />
<br />
This use-case was developed to show how to achieve interoperability with WebLogic.<br />
You can download the example code <a href="https://www.dropbox.com/s/3tci9alqclptt8h/camel-weblogic-osgi.zip?dl=0">here</a>, <br />
<br />
You can extract this file and, using Eclipse, import as an "existing Maven project". You will need to have the M2Eclipse plugin installed.</span><b><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Overview</span></b><b><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"><br />
</span></b><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">The following diagram shows what is happening in the use case created to demonstrate interoperability with WebLogic.<br />
</span><span style="font-family: "arial" , "sans-serif"; font-size: 10pt;"><shapetype coordsize="21600,21600" filled="f" id="_x0000_t75" o:preferrelative="t" o:spt="75" path="m@4@5l@4@11@9@11@9@5xe" stroked="f"><stroke joinstyle="miter"></stroke><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path gradientshapeok="t" o:connecttype="rect" o:extrusionok="f"></path><lock aspectratio="t" v:ext="edit"></lock></shapetype></span><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"><a href="http://1.bp.blogspot.com/_mACIMrbc9PU/TPUs9CxhG-I/AAAAAAAABlw/Ymn2SOCqvss/s1600/camel1.png"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5545387943404837858" src="https://1.bp.blogspot.com/_mACIMrbc9PU/TPUs9CxhG-I/AAAAAAAABlw/Ymn2SOCqvss/s320/camel1.png" style="cursor: pointer; float: left; height: 102px; margin: 0pt 10px 10px 0pt; width: 320px;" /></a><br />
<br />
</span><br />
<br />
<br />
<br />
<br />
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">The use case consists of a Camel route (deployed inside Servicemix) that receives an HTTP message from an external client. The arrival of the HTTP message triggers the route. The route is pretty simple. It simply takes the payload of the HTTP message and drops it onto a WebLogic message queue.<br />
<br />
The HTTP message received (that triggers the route) is a two-way (request/response.) The message exchange pattern (MEP) for any route is generally determined by the first (consumer) endpoint in a route. Therefore the MEP for this particular route is request/response.<br />
<br />
In this route, the JMS producer is responsible for placing the message on the pre-configured WebLogic JMS queue. Because the route is request/response, the JMS producer will by default wait on a response to arrive on the response queue. This response queue is determined by whatever queue name is set in the outgoing JMS message’s JMSReplyTo header. The JMSReplyTo header is a standard-based JMS message header that indicates which address (queue) the JMS consumer that receives the message, should reply to.<br />
<br />
In some cases the replyTo queue could be a temporary queue set up (per-message) by Camel on the fly to listen for reply (dynamic replyTo). In other cases, the replyTo queue will be a well-known location (static replyTo.) In the current use-case the replyTo queue is a well-known (static) location. This follows a pattern common to many JMS applications.</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">To make it easy to test, this example creates a secondary route inside </span><span style="color: #222222; font-family: "courier new"; font-size: 10pt;">WebLogicRoute.java</span><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">. that serves as a “mock” server. This route listens on the “test” queue and transforms the message (simply writes request to response) and places response on the replyTo queue. </span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt;">
<b><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Implementation</span></b><b><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"><br />
</span></b><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">The following shows the Camel code for this route.</span><br />
<br />
<span style="color: #222222; font-family: "courier new"; font-size: 10pt; line-height: 115%;">from("jetty:http://0.0.0.0:8888/placeorder")<br />
.to(“wmq:queue:test?replyTo=testResponse&useMessageIDAsCorrelationID=true");</span><br />
<br />
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">The code simply listens for incoming HTTP messages (via the camel Jetty component) and forwards the payload to a WebLogic queue specified by “wmq:queue:test”. (Note the “wmq:” refers to the bean ID of JMSComponent in the Spring configuration file.) The route sets the value of the “JMSreplyTo” header using an option on the outgoing queue URI. Thus the route, after sending to the “test” queue, will wait on a response on the queue specified in the ‘replyTo’ option. In this case the route will listen for a response on “testResponse”. Camel will by default use a message selector to identify the response message, searching for the response message that has a corrrelationId that matching the messageId of the original message. In this way, Camel handles the message correlation for you without additional code. The response then gets converted and sent back to the original client via HTTP.</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">A secondary route exist merely to “mock” a server and will receive requests and post replies. Typically this will be done by an external process but for our purposes this “mock” service makes the route self-contained and easier to test. Additionally, this secondary route shows just how easy it is to pull messages off a queue, process them, and post replies. The code for this secondary “mock” service is shown below:</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 10pt;">// This can be used to "Mock" Server</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 10pt;">from(“wmq:queue:test?useMessageIDAsCorrelationID=true")<span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 1;"> </span></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span>.to("myTransform");</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Should you decide to use an external Service to pull requests off the “test” queue you can simply comment out this secondary route. </span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt;">
<b style="mso-bidi-font-weight: normal;"><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Spring Configuration</span></b><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"><br />
The Spring configuration for WebLogic, used in this example route is shown below:</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><beans xmlns="http://www.springframework.org/schema/beans"</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span>xsi:schemaLocation="</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span>http://www.springframework.org/schema/beans</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 2;"> </span>http://www.springframework.org/schema/beans/spring-beans.xsd</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 1;"> </span><span style="mso-spacerun: yes;"> </span>http://camel.apache.org/schema/spring</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-tab-count: 2;"> </span>http://camel.apache.org/schema/spring/camel-spring.xsd"></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><camelContext xmlns="http://camel.apache.org/schema/spring"></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><routeBuilder ref="weblogicRoute"/></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span></camelContext></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><bean id="weblogicRoute" class="com.fusesource.example.camel.WebLogicRoute"></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 1;"> </span><!-- This is the "request" queue --></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><property name="requestQueue" value="test"/></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 1;"> </span><!-- This is the "response" queue --><span style="mso-spacerun: yes;"> </span></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><property name="responseQueue" value="testResponse"/></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span></bean></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 1;"> </span><bean id="myTransform" class="com.fusesource.example.camel.MyTransform"/></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate"></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><property name="environment"></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><props></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><prop key="java.naming.provider.url">t3://localhost:7001</prop></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><prop key="java.naming.security.principal">weblogic</prop></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><prop key="java.naming.security.credentials">password1</prop></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span></props></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span></property></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span></bean></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><bean id="jndiFactoryBean" class="org.springframework.jndi.JndiObjectFactoryBean"></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span><property name="jndiName" value="jms/connectionFactory"/></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><property name="jndiTemplate" ref="jndiTemplate"/></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><property name="lookupOnStartup" value="false"/></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><property name="proxyInterface" value="javax.jms.ConnectionFactory"/></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span></bean></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><bean id="jndiDestinationResolver" class="org.springframework.jms.support.destination.JndiDestinationResolver"></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><property name="jndiTemplate" ref="jndiTemplate"/></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span></bean></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-tab-count: 1;"> </span><span style="mso-spacerun: yes;"> </span><bean id="jmsConfiguration" class="org.apache.camel.component.jms.JmsConfiguration"></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><property name="connectionFactory" ref="jndiFactoryBean"/></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><property name="destinationResolver" ref="jndiDestinationResolver"/></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span></bean></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><bean id="wmq" class="org.apache.camel.component.jms.JmsComponent"></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span><property name="configuration" ref="jmsConfiguration" /></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"><span style="mso-spacerun: yes;"> </span></bean></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 9pt;"></beans></span><span style="color: #222222; font-family: "courier new"; font-size: 10pt;"></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 10pt;"></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"><br />
</span><b><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">WebLogic Setup</span></b></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">As a JMS broker, WebLogic is somewhat picky about how things are set up. You are responsible for setting up a server, a domain, a jms module, a subdeployment and a connection factory and a queue.</span></div>
<div class="MsoListParagraphCxSpFirst" style="background: white; line-height: normal; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"><span style="mso-list: Ignore;">1)<span style="font-family: "times new roman";"> </span></span></span><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Set up a server for the following t3://localhost:7001.</span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"><span style="mso-list: Ignore;">2)<span style="font-family: "times new roman";"> </span></span></span><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Set up a connection factory and give jms/connectionFactory as its JNDI name.</span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"><span style="mso-list: Ignore;">3)<span style="font-family: "times new roman";"> </span></span></span><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Set up a queue and give “test” as its JNDI name.</span></div>
<div class="MsoListParagraphCxSpMiddle" style="background: white; line-height: normal; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"><span style="mso-list: Ignore;">4)<span style="font-family: "times new roman";"> </span></span></span><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Set up a queue and give “testResponse” as its jndi name.</span></div>
<div class="MsoListParagraphCxSpLast" style="background: white; line-height: normal; margin: 0in 0in 10pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"><span style="mso-list: Ignore;">5)<span style="font-family: "times new roman";"> </span></span></span><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Make sure Admin Server for the Domain you just created is up before starting the example Camel route.</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt 0.25in;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">A good reference guide for setting up these things inside WebLogic using Oracle Admin Server Console is the following reference:</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"><a href="http://weblogic-wonders.com/weblogic/2010/11/30/weblogic-jms-feature-using-a-queue/">http://weblogic-wonders.com/weblogic/2010/11/30/weblogic-jms-feature-using-a-queue/</a></span><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<b><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Making WebLogic Dependency (JAR) available to Maven</span></b><b><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"><br />
</span></b><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"><br />
When implementing a Camel solution to interoperate with WebLogic MQ, there is a required WebLogic JMS specific client library needed. For the purpose of this example, this library was obtained from an installation of Oracle WebLogic Server 11g for Windows.</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">The specific WebLogic library required at run-time is “wlthint3client.jar”. </span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">To install the library into your local Maven repo, and thus available to Maven build (and Servicemix), go to your WebLogic installation directory and install wlthint3client using appropriate Maven command. (Note: this library has been included for your convenience in the \lib folder of this example.) </span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">For example, if you have installed WebLogic in<span style="mso-spacerun: yes;"> </span>c:\Oracle, the command to install the weblogic client jar into your local maven repo would look like this:</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 10pt;">mvn -e install:install-file -Dfile=C:\Oracle\Middleware\wlserver_10.3\server\lib\wlthint3client.jar -DgroupId=weblogic -DartifactId=weblogic -Dversion=10.3 -Dpackaging=jar</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Once the libraries are added to the local Maven repository as shown above, then the ‘pom.xml’ file for the given project can include the dependencies, using the groupId, artifactId, and version in order to identify the dependency to Maven. Maven should then be able to find the dependency in the local repo and use it when running the unit test. </span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><dependency></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 2;"> </span><groupId>weblogic</groupId></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 2;"> </span><artifactId>weblogic</artifactId></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 1;"> </span><version>10.3</version></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 0pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span></dependency></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Note: We do not instantiate weblogic JMS objects in code, rather they are injected via Spring XML. So there is no compile-time requirement for the Weblogic JAR. The requirement for this dependency to be specified comes only when the unit test is run. We’ll talk more about how to make this JAR available when running the bundle inside Servicemix in the next section.</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<b><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Building the example</span></b><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"><br style="mso-special-character: line-break;" /></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">First make sure you have built the example and installed into local maven repo:</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 10pt;">mvn clean install </span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">This will build the bundle (place the resulting jar into the /target folder), install the bundle into the local Maven respository, and run the JUnit test. </span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">If the build and unit test succeeds you are ready to install the bundle into Servicemix. </span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">As an alternative to running this route in Servicemix, you can also run the camel route in standalone mode (thanks to the camel-maven-plugin in the pom) by typing </span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 10pt;">mvn camel:run</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">You can see the routing rules by looking at the java code in the </span><span style="color: #222222; font-family: "courier new"; font-size: 10pt;">src/main/java</span><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"> directory and the Spring XML configuration lives in </span><span style="color: #222222; font-family: "courier new"; font-size: 10pt;">src/main/resources/META-INF/spring</span><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<b><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Making WebLogic JMS client library Available inside Servicemix (Runtime)</span></b><b><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"><br />
</span></b><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"><br />
The weblogic client library needs to be installed into FUSE ESB (Servicemix) making it available at run time. Assuming you have run the 'mvn install:install-file' command to install the weblogic library into the local maven repository, you should now be able to install the library into Servicemix by pointing Servicemix to the proper location in the local maven repo (using the'wrap:' and 'mvn:' prefix.</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">From the Servicemix command-line console type:</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 8pt;">osgi:install wrap:mvn:weblogic/weblogic/10.3\$Bundle-SymbolicName=weblogic&Bundle-Version=10.3</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Once the dependent runtime Weblogic client JAR file is installed in Servicemix, you can install the WebLogic example route into Servicemix.</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<b style="mso-bidi-font-weight: normal;"><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Installing the Route</span></b></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">You have 3 options for installing the bundle. Choose one of the following techniques.</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">1) Install as feature</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">The pom file does the necessary work to create a feature file representing the bundle. This feature file is installed alongside the bundle into the local maven repository. You can add the feature descriptor to the set of feature descriptors that Servicemix knows about by issuing the following command:</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 8pt;">features:addurl<span style="mso-spacerun: yes;"> </span>mvn:com.fusesource.examples/camel-weblogic-osgi/1.0.0/xml/features</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">You can then install the "</span><span style="color: #222222; font-family: "courier new"; font-size: 10pt;">camel-weblogic-osgi</span><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">" feature by running the following:</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 10pt;">features:install<span style="mso-spacerun: yes;"> </span>camel-weblogic-osgi</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">2) Install as a bundle</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Before doing this make sure the dependent runtime features have been installed:</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 8pt;">features:install camel-jms</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 8pt;">features:install camel-jetty</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 8pt;">osgi:install wrap:mvn:weblogic/weblogic/10.3\$Bundle-SymbolicName=weblogic&Bundle-Version=10.3</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Once above dependencies are successfully installed into Servicemix, you can install the example route into servicemix using the following from the servicemix command console:</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "courier new"; font-size: 10pt;">osgi:install -s mvn:com.fusesource.examples/camel-weblogic-osgi/1.0.0</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">3) Copy JAR into hotdeploy directory</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Before doing this make sure the dependent features specified in option 2 above “Install as a bundle” have been installed. Once these dependencies are successfully installed into Servicemix, you can install the example route while Servicemix is running, drop the file </span><span style="color: #222222; font-family: "courier new"; font-size: 10pt;">target\camel-weblogic-osgi-1.0.0.jar</span><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"> into the </span><span style="color: #222222; font-family: "courier new"; font-size: 10pt;">\deploy</span><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"> directory of your Servicemix installation.</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<b style="mso-bidi-font-weight: normal;"><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Logging and Troubleshooting</span></b></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Make sure there is no other route listening for request on port 8888.</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">To enable logging for this example type:</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">log:set DEBUG<span style="mso-spacerun: yes;"> </span>com.fusesource.example.camel </span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">With logging set to DEBUG for 'com.fusesource.example.camel', search the log for "Message body =" (see the debug statements in MyTransform.java).</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">For an even higher level of logging (logging Camel specifics)</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">log:set DEBUG org.apache.camel</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">See logs in </span><span style="color: #222222; font-family: "courier new"; font-size: 10pt;"><servicemix_home>\data\logs\servicemix.log</span><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;"></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<b style="mso-bidi-font-weight: normal;"><span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Testing the Route</span></b></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">To trigger the route you can perform an HTTP POST at the URL "http://localhost:8888/placeorder", sending in any valid XML as the content of the message. SOAPUI is a good (free) tool for sending test HTTP requests.</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">The route will take the content of the incoming HTTP post and put it on the appropriate queue (as specified in the "camel-context.xml".)</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<span style="color: #222222; font-family: "arial" , "sans-serif"; font-size: 10pt;">Typically, the process that is listening on this queue is external to the route. It is expected that the process will pick up the message and place a response on the designated response queue (copying messageId into correlationId) per JMS request/reply convention. If this pattern is followed by the external process, then Camel will be able to receive the response on expected queue and correlate it with the request.</span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin: 0in 0in 10pt;">
<br /></div>
lcurryhttp://www.blogger.com/profile/01568142368502338154noreply@blogger.com5tag:blogger.com,1999:blog-8028068502920625891.post-84840233222845213702010-11-30T08:41:00.000-08:002017-09-11T17:18:51.468-07:00Camel Integration with WebSphere MQThis post will describe my experience with implementing a Camel route that integrates with WebSphere MQ. The Camel route runs inside Servicemix as an OSGI bundle. I used the Enterprise version of Servicemix from FuseSource available here:<br />
http://fusesource.com/downloads/<br />
<br />
This use-case was developed to show how to achieve interoperability with WebSphere MQ.<br />
You can download the example code<a href="https://www.dropbox.com/s/ydw010euf5l3jyf/camel-mq-osgi.zip?dl=0"> here</a> .<br />
<br />
You can extract this file and, using Eclipse, import as an "existing Maven project". You will need to have the M2Eclipse plugin installed.<br />
<br />
<strong>Overview<br /></strong>The following diagram shows what is happening in the use case created to demonstrate interoperability with WebSphere MQ<br />
<br />
<br />
<v:stroke joinstyle="miter"><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"><v:f eqn="sum @0 1 0"><v:f eqn="sum 0 0 @1"><v:f eqn="prod @2 1 2"><v:f eqn="prod @3 21600 pixelWidth"><v:f eqn="prod @3 21600 pixelHeight"><v:f eqn="sum @0 0 1"><v:f eqn="prod @6 1 2"><v:f eqn="prod @7 21600 pixelWidth"><v:f eqn="sum @8 21600 0"><v:f eqn="prod @7 21600 pixelHeight"><v:path connecttype="rect" extrusionok="f" gradientshapeok="t"><o:lock aspectratio="t" ext="edit"><v:imagedata cropbottom="-3876f" croptop="-2876f" src="file:///C:%5CUsers%5CLowry%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_image001.png" title=""><o:lock aspectratio="f" ext="edit"><a href="http://1.bp.blogspot.com/_mACIMrbc9PU/TPUs9CxhG-I/AAAAAAAABlw/Ymn2SOCqvss/s1600/camel1.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5545387943404837858" src="https://1.bp.blogspot.com/_mACIMrbc9PU/TPUs9CxhG-I/AAAAAAAABlw/Ymn2SOCqvss/s320/camel1.png" style="cursor: pointer; float: left; height: 102px; margin: 0pt 10px 10px 0pt; width: 320px;" /></a><br /><br /><br /><br /><br /><br /><br />The use case consists of a Camel route (deployed inside Servicemix) that receives an HTTP message from an external client. The arrival of the HTTP message triggers the route. The route is pretty simple. It simply takes the payload of the HTTP message and drops it onto a Websphere MQ queue.<br /><br />The HTTP message received (that triggers the route) is a two-way (request/response.) The message exchange pattern (MEP) for any route is generally determined by the first (consumer) endpoint in a route. Therefore the MEP for this particular route is request/response.<br /><br />In this route, the JMS producer is responsible for placing the message on the pre-configured MQ queue. Because the route is request/response, the JMS producer will by default wait on a response to arrive on the response queue. This response queue is determined by whatever queue name is set in the outgoing JMS message’s JMSReplyTo header. The JMSReplyTo header is a standard-based JMS message header that indicates which address (queue) the JMS consumer that receives the message, should reply to.<br /><br />In some cases the replyTo queue could be a temporary queue set up (per-message) by Camel on the fly to listen for reply (dynamic replyTo). In other cases, the replyTo queue will be a well-known location (static replyTo.) In the current use-case the replyTo queue is a well-known (static) location. This follows a pattern common to many JMS applications.<br /><br /><strong>Implementation<br /></strong>The following shows the Camel code for this route.<br /><br /><br /><span style="font-family: "courier new";">from("jetty:http://0.0.0.0:8888/placeorder")<br /><br />.to(targetUri + "?replyTo=SYSTEM.SOAP.RESPONSE.QUEUE");</span><br /><br />The code simply listens for incoming HTTP messages (via the camel Jetty component) and forwards the payload to a Websphere MQ queue. The route sets the value of the “JMSreplyTo” header using an option on the outgoing targetUri. Thus the route, after sending to the targetUri queue, will wait on a response on the queue specified in the ‘replyTo’ option. In this case the route will listen for a response on “SYSTEM.SOAP.RESPONSE.QUEUE”. Camel will by default use a message selector to identify the response message, searching for the response message that has a corrrelationId that matching the messageId of the original message. In this way, Camel handles the message correlation for you without additional code. The response then gets converted and sent back to the original client via HTTP.<br /><br />The Spring configuration for WebSphere MQ, used in above use case is shown below:</o:lock></v:imagedata></o:lock></v:path></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:formulas></v:stroke><br />
<pre class="csharpcode"><beans xmlns=<span class="str">"http://www.springframework.org/schema/beans"</span>
xmlns:xsi=<span class="str">"http://www.w3.org/2001/XMLSchema-instance"</span>
xsi:schemaLocation=<span class="str">"
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd"</span>>
<camelContext xmlns=<span class="str">"http://camel.apache.org/schema/spring"</span>>
<routeBuilder <span class="kwrd">ref</span>=<span class="str">"mqRoute"</span>/>
</camelContext>
<bean id=<span class="str">"mqRoute"</span> <span class="kwrd">class</span>=<span class="str">"com.fusesource.camel.MqRoute"</span>>
<!-- This <span class="kwrd">is</span> the <span class="str">"request"</span> queue -->
<property name=<span class="str">"outgoingQueue"</span> <span class="kwrd">value</span>=<span class="str">"outgoingPayments"</span>/>
<!-- This <span class="kwrd">is</span> the <span class="str">"response"</span> queue -->
<property name=<span class="str">"incomingQueue"</span> <span class="kwrd">value</span>=<span class="str">"incomingPayments"</span>/>
</bean>
<bean id=<span class="str">"myTransform"</span> <span class="kwrd">class</span>=<span class="str">"com.fusesource.camel.MyTransform"</span>/>
<bean id=<span class="str">"wmq"</span> <span class="kwrd">class</span>=<span class="str">"org.apache.camel.component.jms.JmsComponent"</span>>
<property name=<span class="str">"connectionFactory"</span>>
<bean <span class="kwrd">class</span>=<span class="str">"com.ibm.mq.jms.MQConnectionFactory"</span>>
<property name=<span class="str">"transportType"</span> <span class="kwrd">value</span>=<span class="str">"1"</span>/>
<property name=<span class="str">"hostName"</span> <span class="kwrd">value</span>=<span class="str">"localhost"</span>/>
<property name=<span class="str">"port"</span> <span class="kwrd">value</span>=<span class="str">"1414"</span>/>
<property name=<span class="str">"queueManager"</span> <span class="kwrd">value</span>=<span class="str">"QM_TEST"</span>/>
</bean>
</property>
</bean>
</beans></pre>
<v:stroke joinstyle="miter"><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"><v:f eqn="sum @0 1 0"><v:f eqn="sum 0 0 @1"><v:f eqn="prod @2 1 2"><v:f eqn="prod @3 21600 pixelWidth"><v:f eqn="prod @3 21600 pixelHeight"><v:f eqn="sum @0 0 1"><v:f eqn="prod @6 1 2"><v:f eqn="prod @7 21600 pixelWidth"><v:f eqn="sum @8 21600 0"><v:f eqn="prod @7 21600 pixelHeight"><v:path connecttype="rect" extrusionok="f" gradientshapeok="t"><o:lock aspectratio="t" ext="edit"><v:imagedata cropbottom="-3876f" croptop="-2876f" src="file:///C:%5CUsers%5CLowry%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_image001.png" title=""><o:lock aspectratio="f" ext="edit"><span style="font-weight: bold;">Building the example</span><br />First make sure you have built the example and installed into local maven repo:<br /><br /><span style="font-family: "courier new";">mvn install -DskipTests=true</span><br /><br /><br />You can see the routing rules by looking at the java code in the<span style="font-family: "courier new";"> src/main/java</span> directory. The Spring XML configuration lives in src/main/resources/META-INF/spring/camel-context.xml<br /><br /><strong>WebSphere MQ Dependencies</strong><br />When implementing a Camel solution to interoperate with WebSphere MQ, there is a required set of IBM-specific libraries needed. For the purpose of this POC, these libraries were obtained by downloading a WebSphere MQ v. 7.0.1.3 trial for Windows.<br /><br /><strong></strong></o:lock></v:imagedata></o:lock></v:path></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:formulas></v:stroke><strong>Making Dependency Available to Runtime</strong><br />
A set of MQ libraries are required to be installed into FUSE ESB (Servicemix) making them available at run time. This set of dependent runtime JARs is provided as part of a MQ installation. The libraries, and the folder from and MQ installation where they can be found is shown below:<br />
<br />
<span style="font-family: "courier new";">%MQ_INSTALL_DIR%\java\lib\OSGI<br />\com.ibm.mq.osgi.directip_7.0.1.3.jar<br />\com.ibm.msg.client.osgi.commonservices.j2se_7.0.1.3.jar<br />\com.ibm.msg.client.osgi.jms.prereq_7.0.1.3.jar<br />\com.ibm.msg.client.osgi.jms_7.0.1.3.jar<br />\com.ibm.msg.client.osgi.nls_7.0.1.3.jar<br />\com.ibm.msg.client.osgi.wmq.nls_7.0.1.3.jar<br />\com.ibm.msg.client.osgi.wmq.prereq_7.0.1.3.jar<br />\com.ibm.msg.client.osgi.wmq_7.0.1.3.jar<br /></span>These JARs packaged as standard OSGI libraries by IBM and therefore recognizable and deployable into any standard OSGI container. These libraries can be deployed into Servicemix easily using the following commands:<br />
<br />
<span style="font-family: "courier new";">osgi:install -s file:C:/Progra~1/IBM/WebSph~1/java/lib/OSGi/com.ibm.msg.client.osgi.jms.prereq_7.0.1.3.jar<br />osgi:install -s file:C:/Progra~1/IBM/WebSph~1/java/lib/OSGi/com.ibm.msg.client.osgi.jms_7.0.1.3.jar<br />osgi:install -s file:C:/Progra~1/IBM/WebSph~1/java/lib/OSGi/com.ibm.msg.client.osgi.wmq.prereq_7.0.1.3.jar<br />osgi:install -s file:C:/Progra~1/IBM/WebSph~1/java/lib/OSGi/com.ibm.msg.client.osgi.wmq_7.0.1.3.jar<br />osgi:install -s file:C:/Progra~1/IBM/WebSph~1/java/lib/OSGi/com.ibm.msg.client.osgi.nls_7.0.1.3.jar<br />osgi:install -s file:C:/Progra~1/IBM/WebSph~1/java/lib/OSGi/com.ibm.msg.client.osgi.commonservices.j2se_7.0.1.3.jar<br />osgi:install -s file:C:/Progra~1/IBM/WebSph~1/java/lib/OSGi/com.ibm.mq.osgi.directip_7.0.1.3.jar<br />osgi:install -s file:C:/Progra~1/IBM/WebSph~1/java/lib/OSGi/com.ibm.msg.client.osgi.wmq.nls_7.0.1.3.jar<br /></span>All but the last bundle are deployed with the ‘-s’ option (meaning to auto-start the bundle). The last bundle above is a bundle “fragment” so no start is required.<br />
<br />
As a convenience, an optional step is to install these IBM MQ OSGI bundles into your local maven repo (or to a corporate Nexus repository.) If you do this, you would be able to use the Servicemix "mvn:" prefix with osgi:install (rather than "file:") telling Servicemix to use the local Maven settings to find the bundle and install it into the container. First it tries to find "mvn:" prefixed artifacts in the local Maven repository, it then tries any external configured repository.<br />
<br />
<v:stroke joinstyle="miter"><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"><v:f eqn="sum @0 1 0"><v:f eqn="sum 0 0 @1"><span style="font-weight: bold;">Other Dependencies</span><br />There are a few features you need to make sure are installed into the Servicemix container prior<br />to deploying the sample.<br /><br />features:install camel-jetty<br />features:install camel-jms<br />features:install camel-spring<br /><br /><span style="font-weight: bold;">Deploying the sample into Servicemix</span><br /><br />Once all the dependent runtime MQ bundles are installed into Servicemix, you can install<br />the example bundle into Servicemix using the following from the servicemix command console:<br /><br /><span style="font-family: "courier new";">osgi:install -s mvn:com.fusesource.examples/camel-mq-osgi/1.1</span><br /><br />To enable logging for this example type:<br /><span style="font-family: "courier new";">log:set DEBUG com.fusesource.camel</span><br />For an even higher level of logging (logging Camel specifics)<br /><span style="font-family: "courier new";">log:set DEBUG org.apache.camel<br /><br /><span style="font-weight: bold;">Running outside of Servicemix</span></span></v:f></v:f></v:f></v:formulas></v:stroke><br />
As an alternative to running this route in Servicemix, you can also run the camel route<br />
in standalone mode outside of Servicemix using the camel maven plugin (see pom). This allows you to start the route using the "<span style="font-family: "courier new";">mvn camel:run</span>" command.<br />
When you run example using 'mvn camel:run' the camel-maven-plugin will construct a classpath from any Maven dependencies listed in the POM with scope "compile." So in order for maven to find these runtime dependencies, you will need to install this minimal set of IBM runtime libraries in your local maven repository. Similar to the IBM MQ OSGI runtime libraries, these jars can also be found in a installation of IBM MQ. You can install these JARS into your local maven repo as follows (the following assumes you have installed Websphere MQ version 7.)<br />
<br />
<span style="font-family: "courier new";">mvn install:install-file -Dfile=C:\PROGRA~1\IBM\WEBSPH~1\java\lib\com.ibm.mqjms.jar -DgroupId=com.ibm -DartifactId=com.ibm.mqjms -Dversion=7.0.1.3 -Dpackaging=jar</span><br />
<span style="font-family: "courier new";">mvn install:install-file -Dfile=C:\PROGRA~1\IBM\WEBSPH~1\java\lib\dhbcore.jar -DgroupId=com.ibm.mq.dhbcore -DartifactId=dhbcore -Dversion=7.0.1.3 -Dpackaging=jar</span><br />
<span style="font-family: "courier new";">mvn install:install-file -Dfile=C:\PROGRA~1\IBM\WEBSPH~1\java\lib\com.ibm.mq.jmqi.jar -DgroupId=com.ibm.mq -DartifactId=com.ibm.mq.jmqi -Dversion=7.0.1.3 -Dpackaging=jar</span><br />
<br />
<v:stroke joinstyle="miter"><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"><v:f eqn="sum @0 1 0"><v:f eqn="sum 0 0 @1"><v:f eqn="prod @2 1 2"><v:f eqn="prod @3 21600 pixelWidth"><v:f eqn="prod @3 21600 pixelHeight"><v:f eqn="sum @0 0 1"><v:f eqn="prod @6 1 2"><v:f eqn="prod @7 21600 pixelWidth"><v:f eqn="sum @8 21600 0"><v:f eqn="prod @7 21600 pixelHeight"><v:path connecttype="rect" extrusionok="f" gradientshapeok="t"><o:lock aspectratio="t" ext="edit"><v:imagedata cropbottom="-3876f" croptop="-2876f" src="file:///C:%5CUsers%5CLowry%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_image001.png" title=""><o:lock aspectratio="f" ext="edit">It was necessary to take special action to install these artifacts into a well-known location (local Maven Repo) and tag the artifacts with appropriate naming scheme. Note the values specified for groupId/artifactIds are very sensitive to typos (this was the cause of some time spent debugging during testing - so be careful.) I took the liberty to define groupId and artifactId for the Maven artifacts associated with these IBM libraries. These names were based on common Maven conventions. It is unknown whether IBM maintains an appropriate public Maven repository that contains such “official” artifacts but none could be found when implementing the POC. If it is determined that such a public repo exists, then this step might be avoided.<br /><br />Once the libraries are added to the local Maven repository as shown above, then the <span style="font-family: "courier new";">‘pom.xml</span>’ file for the given project can include the dependencies, using the groupId, artifactId, and version in order to identify the dependency to Maven. Maven should then be able to find the dependency in the local repo.<br /><br />As a convenience, an optional step would be to install these jars into your local maven repo (or to a corporate Nexus repository.) In which case you could retrieve the dependencies from there and manually installing the JARS to the local maven repo would not be necessary.<br /></o:lock></v:imagedata></o:lock></v:path></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:formulas></v:stroke><v:f eqn="prod @2 1 2"><v:f eqn="prod @3 21600 pixelWidth"><v:f eqn="prod @3 21600 pixelHeight"><v:f eqn="sum @0 0 1"><v:f eqn="prod @6 1 2"><v:f eqn="prod @7 21600 pixelWidth"><v:f eqn="sum @8 21600 0"><v:f eqn="prod @7 21600 pixelHeight"><v:path connecttype="rect" extrusionok="f" gradientshapeok="t"><o:lock aspectratio="t" ext="edit"><v:imagedata cropbottom="-3876f" croptop="-2876f" src="file:///C:%5CUsers%5CLowry%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_image001.png" title=""><o:lock aspectratio="f" ext="edit"><span style="font-weight: bold;">Testing the Route</span><br />Whether running inside Servicemix or in standlone mode, the technique for triggering the route will be the same. To trigger the route you can perform an HTTP POST at the URL "http://localhost:8888/placeorder", sending in any valid XML as the content of the message. (I use a simple tool like SOAPUI or CURL to send http requests) The route will take the content of the incoming HTTP post and put it on the appropriate queue (as specified in the "camel-context.xml".)<br /><br />As a convenience for testing, a secondary "server simulator" route has been added (see "MqRoute.java") that will listen on the outgoing queue. The route that is listening on this queue will pick up the message and place a response on the designated response queue (copying messageId into correlationId) per JMS request/reply convention. The primary route is then able to receive the response on expected queue and correlate it with the request.<br /><br /><br /><br /><strong></strong></o:lock></v:imagedata></o:lock></v:path></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f><span style="font-weight: bold;"></span><br />
<v:stroke joinstyle="miter"><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"><v:f eqn="sum @0 1 0"><v:f eqn="sum 0 0 @1"><span style="font-family: "courier new";"></span><br /></v:f></v:f></v:f></v:formulas></v:stroke>lcurryhttp://www.blogger.com/profile/01568142368502338154noreply@blogger.com15