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 <b....@phxtecno.com> on 2014/02/13 16:30:29 UTC
Apache Mina2 and HL7 listener
Hi,
I have simple mina2 listener defined in spring bean:
<camel:endpoint id="hl7Listener"
uri="mina2:tcp://192.168.1.195:8812?sync=false&codec=#hl7codec&minaLogger=true&disconnectOnNoReply=false&noReplyLogLevel=DEBUG"/>
And I'm connecting to this listener using HAPI HL7 test panel few clients. I
have also a web page that shows some statistics. I would like to show on
this page if there is any client connected with listener. I though that
since this is TCP I would be able to get somehow sessions count from
endpoint but I cannot find a way to do it in mina2. In mina (1) I found that
you can do something like:
IoAcceptor acceptor = hl7Listener.getAcceptor();
Set<IoSession> sessions =
acceptor.getManagedSessions(hl7Listener.getEndpointUri());
and with sessions.size() I had count of how many clients are actually
connected to this endpoint. Besides that I was able to simply use
session.write() to write message to client.
Is there any possibility to get sessions with Mina2Endpoint?
--
View this message in context: http://camel.465427.n5.nabble.com/Apache-Mina2-and-HL7-listener-tp5747265.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Apache Mina2 and HL7 listener
Posted by Bart <b....@phxtecno.com>.
So there is no way to get connected to endpoint session using mina2 or
somehow with camel?
Maybe there is a way to get already created session for specific address and
port?
I'm really looking for such solution without interfering with camel source
code - I've tried and failed...
--
View this message in context: http://camel.465427.n5.nabble.com/Apache-Mina2-and-HL7-listener-tp5747265p5747432.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Apache Mina2 and HL7 listener
Posted by Bart <b....@phxtecno.com>.
Yeah but this will work only if consumer will send something message to
endpoint. I would like to have an option to get IOSession under connection
and this would not work.
--
View this message in context: http://camel.465427.n5.nabble.com/Apache-Mina2-and-HL7-listener-tp5747265p5747312.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Apache Mina2 and HL7 listener
Posted by Richard Kettelerij <ri...@gmail.com>.
Off the top of my head:
from(mina2://etc/etc)
.process(new Processor() {
@Override
public void process(final Exchange exchange) throws
Exception {
IoSession session =
exchange.getIn().getHeader(Mina2Constants.MINA_IOSESSION, IoSession.class)
}
})
On Fri, Feb 14, 2014 at 9:58 AM, Bart <b....@phxtecno.com> wrote:
> Richard,
> If it will give me the current session then I think this will be enough for
> me however how can I achieve this. I don't see a straight way to get
> MINA_IOSESSSION from Mina2Endpoint - or am I missing something?
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Apache-Mina2-and-HL7-listener-tp5747265p5747304.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Re: Apache Mina2 and HL7 listener
Posted by Bart <b....@phxtecno.com>.
Richard,
If it will give me the current session then I think this will be enough for
me however how can I achieve this. I don't see a straight way to get
MINA_IOSESSSION from Mina2Endpoint - or am I missing something?
--
View this message in context: http://camel.465427.n5.nabble.com/Apache-Mina2-and-HL7-listener-tp5747265p5747304.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Apache Mina2 and HL7 listener
Posted by Richard Kettelerij <ri...@gmail.com>.
Hi,
I think you need the IoService [1] in Mina2 to get to the sessions. As far
as I know the camel-mina2 component doesn't expose this. But as Claus
suggested you're welcome to expand the component with said functionality
and contribute it to the community.
Note that it is already possible to easily obtain a session from the
camel-mina2 component using the Mina2Constants.MINA_IOSESSION header. But
this gives you the current session not all sessions which I belief you're
after, right?
[1]
https://mina.apache.org/mina-project/userguide/ch3-service/io-service.html
Kind regards,
Richard
On Fri, Feb 14, 2014 at 9:22 AM, Claus Ibsen <cl...@gmail.com> wrote:
> On Fri, Feb 14, 2014 at 9:01 AM, Bart <b....@phxtecno.com> wrote:
> > Hi Claus,
> > Indeed I had look on camel-mina2 API and it's different especially if you
> > take Endpoint under consideration:
> > 1. MinaEndpoint -
> >
> http://camel.apache.org/maven/current/camel-mina/apidocs/org/apache/camel/component/mina/MinaEndpoint.html
> > 2. Mina2Endpoint -
> >
> http://camel.apache.org/maven/camel-2.12.0/camel-mina2/apidocs/org/apache/camel/component/mina2/Mina2Endpoint.html
> >
> > You can clearly see that MinaEndpoint has additional methods like:
> > - getAcceptor()
> > - getAddress()
> >
> > and those I used with Mina 1 but in Mina2Endpoint there is no such
> methods
> > so I was wondering if there is rather some camel approach with Endpoint
> to
> > get sessions rather than using Mina 2. I would say that external
> application
> > is connecting with my Endpoint - it's a consumer. Is there any way to get
> > all connected consumers with endpoint and send them message?
> >
>
> Ah you are welcome to dive into the camel-mina2 code, to see if you
> can find out where to add code so it can offer the same functionality
> as camel-mina does.
>
> We love contributions
> http://camel.apache.org/contributing
>
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Apache-Mina2-and-HL7-listener-tp5747265p5747299.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> 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
> Make your Camel applications look hawt, try: http://hawt.io
>
Re: Apache Mina2 and HL7 listener
Posted by Bart <b....@phxtecno.com>.
Claus,
I don't think I have such skills :) However I found that problem lies in
that some libraries has been moved from org.apache.mina.common to
org.apache.mina.core.service and MinaEndpoint (1 not 2) cannot find some
libraries:
import org.apache.mina.common.IoAcceptor;
import org.apache.mina.common.IoAcceptorConfig;
import org.apache.mina.common.IoConnector;
import org.apache.mina.common.IoConnectorConfig;
import org.apache.mina.common.IoSession;
is there any way to load mina.common with camel 2.12.2??
--
View this message in context: http://camel.465427.n5.nabble.com/Apache-Mina2-and-HL7-listener-tp5747265p5747303.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Apache Mina2 and HL7 listener
Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Feb 14, 2014 at 9:01 AM, Bart <b....@phxtecno.com> wrote:
> Hi Claus,
> Indeed I had look on camel-mina2 API and it's different especially if you
> take Endpoint under consideration:
> 1. MinaEndpoint -
> http://camel.apache.org/maven/current/camel-mina/apidocs/org/apache/camel/component/mina/MinaEndpoint.html
> 2. Mina2Endpoint -
> http://camel.apache.org/maven/camel-2.12.0/camel-mina2/apidocs/org/apache/camel/component/mina2/Mina2Endpoint.html
>
> You can clearly see that MinaEndpoint has additional methods like:
> - getAcceptor()
> - getAddress()
>
> and those I used with Mina 1 but in Mina2Endpoint there is no such methods
> so I was wondering if there is rather some camel approach with Endpoint to
> get sessions rather than using Mina 2. I would say that external application
> is connecting with my Endpoint - it's a consumer. Is there any way to get
> all connected consumers with endpoint and send them message?
>
Ah you are welcome to dive into the camel-mina2 code, to see if you
can find out where to add code so it can offer the same functionality
as camel-mina does.
We love contributions
http://camel.apache.org/contributing
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Apache-Mina2-and-HL7-listener-tp5747265p5747299.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
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
Make your Camel applications look hawt, try: http://hawt.io
Re: Apache Mina2 and HL7 listener
Posted by Bart <b....@phxtecno.com>.
Hi Claus,
Indeed I had look on camel-mina2 API and it's different especially if you
take Endpoint under consideration:
1. MinaEndpoint -
http://camel.apache.org/maven/current/camel-mina/apidocs/org/apache/camel/component/mina/MinaEndpoint.html
2. Mina2Endpoint -
http://camel.apache.org/maven/camel-2.12.0/camel-mina2/apidocs/org/apache/camel/component/mina2/Mina2Endpoint.html
You can clearly see that MinaEndpoint has additional methods like:
- getAcceptor()
- getAddress()
and those I used with Mina 1 but in Mina2Endpoint there is no such methods
so I was wondering if there is rather some camel approach with Endpoint to
get sessions rather than using Mina 2. I would say that external application
is connecting with my Endpoint - it's a consumer. Is there any way to get
all connected consumers with endpoint and send them message?
--
View this message in context: http://camel.465427.n5.nabble.com/Apache-Mina2-and-HL7-listener-tp5747265p5747299.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Apache Mina2 and HL7 listener
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Did you look at the camel-mina2 api? AFAIR the code is similar to mina
1.x, so hopefully you can do the same.
On Thu, Feb 13, 2014 at 4:30 PM, Bart <b....@phxtecno.com> wrote:
> Hi,
> I have simple mina2 listener defined in spring bean:
> <camel:endpoint id="hl7Listener"
> uri="mina2:tcp://192.168.1.195:8812?sync=false&codec=#hl7codec&minaLogger=true&disconnectOnNoReply=false&noReplyLogLevel=DEBUG"/>
>
> And I'm connecting to this listener using HAPI HL7 test panel few clients. I
> have also a web page that shows some statistics. I would like to show on
> this page if there is any client connected with listener. I though that
> since this is TCP I would be able to get somehow sessions count from
> endpoint but I cannot find a way to do it in mina2. In mina (1) I found that
> you can do something like:
> IoAcceptor acceptor = hl7Listener.getAcceptor();
> Set<IoSession> sessions =
> acceptor.getManagedSessions(hl7Listener.getEndpointUri());
>
> and with sessions.size() I had count of how many clients are actually
> connected to this endpoint. Besides that I was able to simply use
> session.write() to write message to client.
>
> Is there any possibility to get sessions with Mina2Endpoint?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Apache-Mina2-and-HL7-listener-tp5747265.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
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
Make your Camel applications look hawt, try: http://hawt.io