Extending the TCPIP Client Nodes sample
This extension demonstrates how to extend the sample to incorporate a separate,
stand-alone TCP/IP server, in place of the TCPIPServerSimulation flow that is described in the
asynchronous sample, that is configured to echo data back to a connecting client.
This extension also demonstrates how to override some of the connection properties by using the
local environment.
Overview of sample extension:
- The input message that is put onto the TCPIP_ASYNC_IN queue can be modified to contain
information about the host name and port of the TCP/IP server.
- The JavaCompute node in the TCPIPAsyncOut flow copies this information into
the local environment.
- The TCPIPClientOutput node is configured on the Request tab in
the Properties view to be able to accept overrides on certain connection details from the local
environment.
The overrides to the port, host name, or both are present in the local environment,
causing the TCPIPClientOutput node to seek a connection by using the
details in the local environment.
- The message can therefore be routed dynamically to your TCP/IP server without any modification
to the TCPIPAsyncOut message flow.
- The new connection details must also be set in the TCPIPClientInput node
in the TCPIPAsyncIn message flow,
to ensure that this node receives the response from the TCP/IP server.
- A sample input message and .mbtest file
are provided with the sample,
and they assume that your TCP/IP server is listening on localhost:7778.
Running the sample extension:
- Modify the message flows to communicate with your TCP/IP sever by using one of the
following options:
- If your TCP/IP server is listening on localhost:7778 modify the
Connection details property of the TCPIPClientInput node in the TCPIPAsyncIn
message flow to localhost:7778. Save the message flow.
- If your TCP/IP server is not listening on localhost:7778,
complete the following steps:
- Within the TCPIPClientNodesSampleFlowProject, open the
AsyncExtendMessage.xml file.
- Modify AsyncExtendMessage.xml
to change the port,
host name, or both, from localhost:7778 to the
port that your TCP/IP server
is listening on. Save the file.
- Open TCPIPAsyncExtendTest.mbtest. Click
Enqueue, click
Import Source
and import AsyncExtendMessage.xml.
Save this test file.
- Modify the Connection details property of the
TCPIPClientInput node in the
TCPIPAsyncIn message flow to match those in your test message.
Save the message flow.
- Ensure that the TCPIPClientNodesSampleArchive.bar BAR file
contains the asynchronous, rather than the synchronous, message flows.
If you have modified the flows as shown in the previous step,
rebuild and save the BAR file:
- In the WebSphere Message Broker Toolkit, select and open
TCPIPClientNodesSampleArchive.bar
with the Broker Archive editor.
Select the Prepare tab, and click
Build broker archive.
Save the BAR file.
- Deploy the BAR file into the TCPIPClientNodesSampleExecutionGroup.
- Open TCPIPAsyncExtendTest.mbtest, click
Enqueue,
and click Send Message. The following events occur:
- The modified message is sent into the TCPIPAsyncIn message flow.
- The JavaCompute node copies the updated host name and port into the local environment
($LocalEnvironment/Destination/TCPIP/Output/).
- The TCPIPClientOutput node sends the data by using the Connection details
that have been overridden in the local environment.
- The TCP/IP server picks up this data and echoes it back on the same port.
- This data is received by the TCPIPClientInput node in the TCPIPAsyncIn message flow,
which processes the data in the same way in which it processed
the data in the asynchronous sample.
- Click Dequeue, and then click
Get Message.
- Check that the updated message has been sent back over WebSphere MQ successfully:
- View the reply message in the Detailed Properties panel by using the XML Structure view.
- Compare this message with the message previously sent through the Enqueue event.
Unless the TCP/IP server has altered the message body, the two messages are identical.
If all the previous steps are successful, the sample is complete.
Look at the nodes in the three message flows to see how the
results were achieved.
The Connection details property on the Basic
tab looks similar to the following screen capture:
Back to sample home