DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Securing Your Software Supply Chain with JFrog and Azure
Register Today

Trending

  • Database Integration Tests With Spring Boot and Testcontainers
  • Introduction to Domain-Driven Design
  • Operator Overloading in Java
  • The SPACE Framework for Developer Productivity

Trending

  • Database Integration Tests With Spring Boot and Testcontainers
  • Introduction to Domain-Driven Design
  • Operator Overloading in Java
  • The SPACE Framework for Developer Productivity
  1. DZone
  2. Coding
  3. Languages
  4. Intercepting Messages on TCP/IP in Mule

Intercepting Messages on TCP/IP in Mule

This tutorial will walk you through the steps of setting Mule to transform and intercept messages in real time with Anypoint Studio.

Sumit Bansal user avatar by
Sumit Bansal
·
May. 06, 17 · Tutorial
Like (1)
Save
Tweet
Share
6.15K Views

Join the DZone community and get the full member experience.

Join For Free

In this article, we will see how Mule can intercept messages on the TCP/IP socket for real-time communication. Messages will be received on the TCP/IP socket and then will be transformed from byte to object, then object to XML, and then from XML to JSON using Mule out-of-box transformers.

The TCP transport allows sending or receiving messages over TCP connections. TCP is a layer over IP and is used to implement many other reliable protocols such as HTTP and FTP. If you want to use the TCP transport directly then you require a specific protocol for reading the message payload that is not supported by one of these higher level protocols. This is often the case when communicating with legacy or native system applications that don’t support web services. TCP transport is also used in business scenarios where the nature of transactions is in real time.

Scenario

The message will be sent from the Packet Sender application and Mule will receive the message on TCP/IP socket and then it will be transformed from byte to object, then from object to XML, and then from XML to JSON using Anypoint Studio transformers.

Image title

1. TCP Transport will be configured as follows.

a. The exchange pattern will be one-way as we are not sending any acknowledgment back. Then the host and port need to be given. Then connector configuration needs to be defined:Image title

b. The MIME type will be text/plain and response timeout will be default. Image title

c. The first radio box will be checked "Do not use a Reconnection strategy."Image title

d. Choose the protocol as per your requirement and keep the socket alive by checking the box as shown below.Image title

2. The MIME type will be "text/plain" in the Byte Array to Object transformer. 
Image title

3. The MIME type will be "text/xml" in the Object to XML transformer.Image title

4. The MIME type will be "text/JSON" in the XML to JSON transformer.Image title

5. All logger components will be configured as  #[payload]  to log received payloads in the console.

6. Send the packet from the Packet Sender application on the TCP socket for the below configuration. Packet payload is "MULE ESB TEST PACKET."Image title

7. Run the application in debug mode so that we can stop the application and can see the in-flight conversion of data while going from one component to another. 

8. After passing the Byte Array to Object component, the payload is received as text/plain payload. Image title

9. After passing the Object to XML component, the payload is converted to XML format. Image title

10. After passing the XML to JSON component, the payload is converted from XML to JSON format. Image title

11. All the data format changes can be seen in the console, too. Image title

Please refer to this MuleSoft page for more details and information.

XML Object (computer science) application Payload (computing) Transmission Control Protocol JSON Protocol (object-oriented programming) Data Types Data (computing)

Opinions expressed by DZone contributors are their own.

Trending

  • Database Integration Tests With Spring Boot and Testcontainers
  • Introduction to Domain-Driven Design
  • Operator Overloading in Java
  • The SPACE Framework for Developer Productivity

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: