Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

Is a ServerSocket Producer possible

$
0
0
Hi

Im trying to do the following

from("timer:gps")
.routeId("gps")

.setBody().constant("$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47")
.log("${body}")
.to("netty4:tcp://0.0.0.0:9999")

The idea is to be able to do "nc localhost 9999" and see a stream of
messages 1 per second

However this gives
java.net.ConnectException: Cannot connect to 0.0.0.0:9999
at
org.apache.camel.component.netty4.NettyProducer.openChannel(NettyProducer.java:421)
at
org.apache.camel.component.netty4.NettyProducer$NettyProducerPoolableObjectFactory.makeObject(NettyProducer.java:486)

...
.to("netty4:tcp://localhost:9999")

also tries to make a socket connection to localhost as I would expect, is
there an option to create a server socket?

Ive also tried
....
.to("netty4:tcp://:9999")

But that gives
java.lang.IllegalArgumentException: hostname can't be null
at java.net.InetSocketAddress.checkHost(InetSocketAddress.java:149)
at java.net.InetSocketAddress.<init>(InetSocketAddress.java:216)
at
org.apache.camel.component.netty4.NettyProducer.openConnection(NettyProducer.java:356)

However they always appear to create a Socket rather than a ServerSocket.

Is there a way with netty or mina to create the ServerSocket.

I have tried to use a consumer with sync=true however the trigger for the
sending of the message is not an incoming message so that doesnt appear to
work. Or is there an option I need to add to not wait for an incoming
message. Although a solution like that would complicate the logic of sending
the messages.

Please tell me if what I require can be done in camel out of the box, or do
I need to write a custom component?

Viewing all articles
Browse latest Browse all 5648

Trending Articles