You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Bartłomiej Buczek <b....@phxtecno.com> on 2013/09/18 12:51:00 UTC

Endpoint, Routes and client connection

Hi,
I'm having a problem with getting client socket connection or with 
understanding how camel should work. Basically I have spring 
configuration in which I placed:
<camel:camelContext id="Camel">
     <camel:package>com.hl7.test</camel:package>
     <camel:template id="producerTemplate"/>
     <camel:endpoint id="hl7Listener" 
uri="mina2:tcp://192.168.1.195:8812?sync=true&amp;codec=#hl7codec"/>
</camel:camelContext>

and a route:
from("hl7Listener").to("lookupService");


Now I'm connecting client and if client send anything I can pick it up 
in lokupService and client in case of HL7 receives HL7 ACK message which 
works great.
But I would like to send something else also to that connected client. 
Client connects and is connected for whole the time. It sends sometimes 
messages and get ACK messages as response. But how can I send anything 
else to that client? Is there anyway to do it?
I simply want to be able to speak with client so on the base on 
client/server connection. I will have only 1 client connected.


Re: Endpoint, Routes and client connection

Posted by Bart <b....@phxtecno.com>.
I'm trying to go forward with this.
I have a few doubts and questions:
1. Route like:
        from("hl7Listener").to("lookupService");
is only invoke when actually something is send by client to listener. Am I
right?

In this way I can slightly change that route to:
from("hl7Listener").process(new Processor()
{
    @Override
    public void process(Exchange exchange) throws Exception
    {
        exchange.getOut().setBody("test");
    }
});

but this will allow me to send message to client only when he sent something
to listener. I want to be able to send message to client any time I want.


2. I'm debugging this with IntelliJ and in camelContext when I connect
client I can see some changes. When I connect client I can see that deep
down in camelContext there is something like managedSessions. If I connect 1
client I see 1 mangedSession, if I connect 2 client I can see 2 managed
sessions. 
So I think that those sessions are mine connected clients. Is there anyway
that I can fetch these clients from camelContext and send them a message
like with:
exchange.getOut().setBody("test"); 



--
View this message in context: http://camel.465427.n5.nabble.com/Endpoint-Routes-and-client-connection-tp5739738p5739821.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Endpoint, Routes and client connection

Posted by Bart <b....@phxtecno.com>.
Ok I described it badly I suppose. Maybe I'm making a bad approach. I'm
looking for such a soulution:
1. Create a server that can receive/send messages.
2. Clients connects to that server and can send messages.
3. Because we have client-server situation the server should also be able to
send messages to client.

Maybe example would describe it better:
1. Setup a server on 192.168.1.100:8070. Start server.
2. Connect client to server 192.168.1.100:8070.
3. Server knows that client is connected to it so via Socket it can send
message
4. Client is connected to server so via connection can send messages as
well.

I'm still not quite sure if I correctly or clearly described the situation.
If no then please let me know I'll post a code in pure java.

Now from my understanding I set up listener (server) with camelContext and I
setup route:
from("hl7Listener").to("lookupService"); 

so everything that come into listener is forwarded to lookupService - so
it's a situation that client send a message to listener.
Now this client is connected to listener - so how can I send message from
listener to client?

I see it like a client-server chat (exchanging messages). But I have no idea
how to send something to that connected client.
I don't want to extend hl7codec I've just want to send messages to that
connected client (I assume that some kind of socket it opening during client
connection to listener).






--
View this message in context: http://camel.465427.n5.nabble.com/Endpoint-Routes-and-client-connection-tp5739738p5739753.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Endpoint, Routes and client connection

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Not sure we follow.

You want a TCP listener that supports HL7 and "something else" at the same time?
If so you would need to extend the hl7 codec to "figure out when to
speak HL7 and when to speak something else". Or write your own codec
or something else.

Just seems a bit odd though.

Why not have 2 listeners. One for HL7 and another for "something else".


On Wed, Sep 18, 2013 at 12:51 PM, Bartłomiej Buczek
<b....@phxtecno.com> wrote:
> Hi,
> I'm having a problem with getting client socket connection or with
> understanding how camel should work. Basically I have spring configuration
> in which I placed:
> <camel:camelContext id="Camel">
>     <camel:package>com.hl7.test</camel:package>
>     <camel:template id="producerTemplate"/>
>     <camel:endpoint id="hl7Listener"
> uri="mina2:tcp://192.168.1.195:8812?sync=true&amp;codec=#hl7codec"/>
> </camel:camelContext>
>
> and a route:
> from("hl7Listener").to("lookupService");
>
>
> Now I'm connecting client and if client send anything I can pick it up in
> lokupService and client in case of HL7 receives HL7 ACK message which works
> great.
> But I would like to send something else also to that connected client.
> Client connects and is connected for whole the time. It sends sometimes
> messages and get ACK messages as response. But how can I send anything else
> to that client? Is there anyway to do it?
> I simply want to be able to speak with client so on the base on
> client/server connection. I will have only 1 client connected.
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen