Mule 3.5.0 CE creating dynamic inbound endpoints - tcp

I am working with a large collection of TCP connections on my mule application and I want to programmatically add inbound endpoints to a composite source.
I have 70+ applications that need to connect to mule where the application is acting as the TCP server and Mule is the TCP client. In Mule 2 there was a way to dynamically add inbound endpoints to the Mule application and this was changed in Mule 3.
Is there a way to add inbound endpoints to one flow or many flows programmatically on mule startup?
I am using Mule 3.5.0 CE. Any input would be greatly appreciated.

You need to implement MuleContextAware and Initialisable. Here is a rough example that does it for a list of JMS queues. It will be fairly simple to change this to TCP:
https://gist.github.com/ryandcarter/c6d612977585c914114d
It programatically creates a Flow and CompositeSource and calls a vm endpoint to get back into Mule config.

Related

What is more suitable: A windows service or WCF service?

I am creating a web app. I want to create a listening service (TCP) that listens continuously and updates web page according to that.
A Windows service or a WCF service?
At the end I just want a background service that listens on a socket continuously and update data in database. and when database is updated I will use signal r to show that in my page.
Right now I am trying with WCF but I am wondering if it can be done with Windows service also. And right now this application will work on LAN. But in the future, it can also be in the cloud.
First of all, it is important to understand that a Windows service and a WCF service are not the same.
A Windows service is a specialized executable that runs in the background on Windows.
A WCF service is a specialized piece of code that exposes some functionality through a well-defined endpoint. It does not run on its own, but instead must be hosted by some parent process, like IIS, a desktop application, or even a Windows service.
In thinking about the problem you've described, I suppose the most fundamental question to ask is whether or not you have control over the data that will be received via the TCP connection. WCF is built on the notion of the ABCs (Address, Binding, and Contract), all of which have to match in order to facilitate data exchange between WCF endpoints. For example, if you wish to expose a WCF endpoint via IIS that accepts TCP connections from some remote WCF endpoint, the remote WCF endpoint needs to send data to your IIS-hosted WCF endpoint using the agreed-upon data contract. Absent that, WCF will not work. So, if you cannot define the data contract to be used between WCF endpoints, then you'll need to find another option. An option that will work is to open a TCP listener within a Windows service, process the data as it is received, update your database, and listen for more data.
================================================
By way of example, I work on a project that has a front-end desktop application that communicates with a back-end Windows service. We build both the application and the Windows service, so we have full control over the data exchange between the two processes. At one point in time, we used WCF as the mechanism for data exchange. The Windows service would host a WCF service that exposed a NetNamedPipeBinding, which we later on changed to NetTcpBinding to get around some system administration issues. The application would then create its own endpoint to communicate with the WCF service being hosted within the Windows service.
This worked fine.
As our system got more mature, we needed to start sending more and more information from the Windows service to the application. If I recall correctly, I believe we experimented with streaming within WCF and concluded that the overhead was not something we could tolerate. So, we used WCF to exchange commands and status information between the application and the Windows service, but we simultaneously used a TCP socket connection to stream the data from the Windows service to the application.
This worked fine.
When we got a chance to update the Windows service software, we decided that it would be better to have a single communication mechanism between the Windows service and the application. So, we replaced WCF altogether with a TCP socket connection that uses a homegrown messaging protocol to exchange information in both directions - application to Windows service and Windows service to application.
This works fine and is the approach we've used for a couple of years now.
HTH

Integrating Spring MVC with Spring Integration

I'm trying to connect my existing Spring MVC application with Spring integration but I can't find how to send a TCP message to an specific client.
I have lot of devices connected to my server over TCP and I'm using DirectChannel to get them connected.
Is there any way to specify the client who will receive the message when I call SimpleGatewy.send()?
Thanks.
See the tcp-client-server sample which uses a gateway - this can be invoked from any code, including a controller.

How to configure a Message Driven Bean to subscribe to a remote JMS Topic

I am trying to get a MessageDriven (EJB 3) bean to subscribe to a JMS Topic on another glassfish instance on another host. Is this possible?
In the Glassfish console you can modify the JMS server and point it to another Glassfish instance or a standalone OpenMQ broker. Although you can configure several JMS hosts to my knowledge Glassfish will always use the one called default_JMS_host so that's the one you want to edit.
Just one thing: in such a setup the two server instances will share queues and topics, which may not be what you want if the two servers are for example running the same application but don't want to share e.g a particular queue. This can easily be solved via the Destination Resources configuration, by specifying different physical names for that queue.

Create Custom WSO2 ESB Transport

I want to create a new transport processor on WSO2 ESB. This transport is to provide ISO 8583 message processing and transform Raw TCP to SOAP message, vice versa. On the source code, there is a transport management object and inherited by several transport service class such as JMS, HTTP, HTTPS, etc. I have several questions:
How the transport management object works?
Is that possible to recode TCP service source code and redeploy with my customized actions?
Thanks.
WSO2 ESB is backed by Apache Synapse and it uses Axis2 Transports to provide the transport layer. You can write a new Axis2 transport and plug it to WSO2 ESB. resources can be found at here and here.
Regards,
/nuwan
Another way to expose the raw TCP to the ESB, could be to create an ActiveMQ queue to listen the raw TCP and make them available to the ESB.
There are custom transport implementations in the WSO2 ESB which has written for specific customer requirements. FIX (Financial Information Exchange) is such a custom transport. You can get an idea about writing a custom transport if you go through the source code of this transport.
https://github.com/wso2/wso2-synapse/tree/master/modules/transports/optional/fix
Here is a blog post which I have written to explain the process of creating a custom transport for ISO8583 protocol.
http://soatutorials.blogspot.com/2015/06/extending-wso2-esb-with-custom_21.html

How do I open a connection back to the server using Flex?

I want to open a connection back to the server using Flex so I can stream chat messages to the Flex front-end. How do I do this and does Flex enforce any same-origin restrictions on ports or subdomains?
You'll have to use a messaging server software and then use the Producer and Consumer classes in the Flex framework to send and receive messages.
What you need depends on what server you are running on. If you are on a Java stack, you can use BlazeDS and ActiveMQ.
If you are streaming/consuming from and to different domains, you'll need to setup a crossdomain file that allows the inter-domain communication.

Resources