Incorrect channel is set in the NMR

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Incorrect channel is set in the NMR

Edell Nolan
Hi,

I am trying to run a demo against the latest kit but I seem to have hit an
issue in the

org.apache.servicemix.jbi.runtime.impl.DeliveryChannelImpl =>

In the getChannelToUse there is a note about a TODO - I seem to have a case
where I have an internal and external endpoint
that have the same service name and endpoint name.

the basic sequence of events of the demo is as follows

I have an external service that submits a request using soap/http to a
service thats deployed in smx from there it is routed through a few services
based on content etc and eventually uses a CBR service based on content to
make an external call using soap/http to an another external service.

In the first attempt to make the call from the external service to the
service deployed within servicemix after debugging this code It has two
matching endpoints and as seen below none of them gets set so I end up with
a Null pointer exception in AssemblyReferencesListener due to no assembly
but its because the channel is wrong.

If I force the below to use one of the matching endpoints then I can proceed
with my call going into myService but when it attempts to make an external
call back out I end up with no match and again the channel is wrong and
falls over with a Null pointer Exception.

Is there a way I can get around this ?

thanks, Edell.


protected Channel getChannelToUse(InternalExchange exchange) {
        Channel channelToUse = channel;
        if (exchange.getSource() == null) {
            // We need to look up the channel corresponding to the sender
endpoint
            try {
                String sender = (String)
exchange.getProperty(SENDER_ENDPOINT);
                if (sender != null) {
                    int idx = sender.lastIndexOf(':');
                    String svc = sender.substring(0, idx);
                    String ep = sender.substring(idx + 1);
                    Map<String, Object> props =
ServiceHelper.createMap(Endpoint.SERVICE_NAME, svc,

Endpoint.ENDPOINT_NAME, ep);
                    // TODO: we may be using the wrong channel if both an
internal endpoint and an external endpoint
                    // have been registered with the same svc / ep name
                    List<Endpoint> eps =
channel.getNMR().getEndpointRegistry().query(props);
                    if (eps != null && eps.size() == 1) {
                        channelToUse = ((InternalEndpoint)
eps.get(0)).getChannel();
                    }
                }
            } catch (Throwable t) {
                // Ignore
            }
        } else {
            channelToUse = exchange.getSource().getChannel();
        }
        return channelToUse;
    }
Reply | Threaded
Open this post in threaded view
|

Re: Incorrect channel is set in the NMR

Guillaume Nodet
Administrator
The NMR endpoints are now registered with either an INTERNAL_ENDPOINT
property or an EXTERNAL_ENDPOINT property set to true.
So this means we could add this property the props variable in order
to select the right endpoint.
The next question is: do we know if the target endpoint is an internal
endpoint or an external endpoint ?
A new test case inside jbi/itests would be nice for that.

Anyway, I'm not so sure it will actually affect the routing.
In this bit of code, the goal is to find the channel corresponding to
the endpoint, but if it's not found, it should use the channel for the
component itself, which should still work.

Could you paste the stack trace of the NPE you had ?  Maybe this one
should be fixed instead.

On Mon, Jun 8, 2009 at 19:06, Edell Nolan<[hidden email]> wrote:

> Hi,
>
> I am trying to run a demo against the latest kit but I seem to have hit an
> issue in the
>
> org.apache.servicemix.jbi.runtime.impl.DeliveryChannelImpl =>
>
> In the getChannelToUse there is a note about a TODO - I seem to have a case
> where I have an internal and external endpoint
> that have the same service name and endpoint name.
>
> the basic sequence of events of the demo is as follows
>
> I have an external service that submits a request using soap/http to a
> service thats deployed in smx from there it is routed through a few services
> based on content etc and eventually uses a CBR service based on content to
> make an external call using soap/http to an another external service.
>
> In the first attempt to make the call from the external service to the
> service deployed within servicemix after debugging this code It has two
> matching endpoints and as seen below none of them gets set so I end up with
> a Null pointer exception in AssemblyReferencesListener due to no assembly
> but its because the channel is wrong.
>
> If I force the below to use one of the matching endpoints then I can proceed
> with my call going into myService but when it attempts to make an external
> call back out I end up with no match and again the channel is wrong and
> falls over with a Null pointer Exception.
>
> Is there a way I can get around this ?
>
> thanks, Edell.
>
>
> protected Channel getChannelToUse(InternalExchange exchange) {
>        Channel channelToUse = channel;
>        if (exchange.getSource() == null) {
>            // We need to look up the channel corresponding to the sender
> endpoint
>            try {
>                String sender = (String)
> exchange.getProperty(SENDER_ENDPOINT);
>                if (sender != null) {
>                    int idx = sender.lastIndexOf(':');
>                    String svc = sender.substring(0, idx);
>                    String ep = sender.substring(idx + 1);
>                    Map<String, Object> props =
> ServiceHelper.createMap(Endpoint.SERVICE_NAME, svc,
>
> Endpoint.ENDPOINT_NAME, ep);
>                    // TODO: we may be using the wrong channel if both an
> internal endpoint and an external endpoint
>                    // have been registered with the same svc / ep name
>                    List<Endpoint> eps =
> channel.getNMR().getEndpointRegistry().query(props);
>                    if (eps != null && eps.size() == 1) {
>                        channelToUse = ((InternalEndpoint)
> eps.get(0)).getChannel();
>                    }
>                }
>            } catch (Throwable t) {
>                // Ignore
>            }
>        } else {
>            channelToUse = exchange.getSource().getChannel();
>        }
>        return channelToUse;
>    }
>



--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com
Reply | Threaded
Open this post in threaded view
|

Re: Incorrect channel is set in the NMR

Edell Nolan
included is my stackTrace


I get the following error from a CBRService - it has picked the correct
external service

The following is from my xbean.xml file of my cbrService

<camelContext xmlns="http://activemq.apache.org/camel/schema/spring"
              xmlns:logisticx="http://logisticx.demo.fuse.iona.com/"
              xmlns:ns1="
http://logisticx.demo.fuse.iona.com/warehouseService/">

    <route>
      <from
              uri="jbi:endpoint:
http://logisticx.demo.fuse.iona.com//cbrService/cbrEndpoint"/>

          <choice>
            <when>
              <xpath>/ns1:inStock/arg0/lineItem/itemId/text() =
'1002'</xpath>
              <to
                      uri="jbi:endpoint:
http://logisticx.demo.fuse.iona.com/warehouseService//WarehouseService/WarehouseEndpoint?mep=in-out,operation=http://logisticx.demo.fuse.iona.com/warehouseService/:instock"/>

            </when>

     .................

</camelContext>

then I have a cxfbc:provider which has

    <cxfbc:provider service="ware:WarehouseService"
        endpoint="WarehouseEndpoint" useJBIWrapper="false"
            wsdl="classpath:warehouse.wsdl"
        locationURI="http://localhost:8080/warehouse/services/warehouse"/>


10:42:39,133 | DEBUG | x-camel-thread-3 | NMR                              |
.servicemix.nmr.core.ChannelImpl  274 | Channel
org.apache.servicemix.nmr.core.ChannelImpl@f96093 dispatching exchange: [
  id:        884874dd-e7e7-4357-8fb5-6765c12974fb
  mep:       InOut
  status:    Active
  role:      Consumer
  target:    PropertyMatchingReference[{SERVICE_NAME={
http://logisticx.demo.fuse.iona.com/warehouseService/}WarehouseService,
ENDPOINT_NAME=WarehouseEndpoint}]
  operation: {http://logisticx.demo.fuse.iona.com/warehouseService/}inStock
  properties: [
      javax.jbi.ServiceEndpoint =
org.apache.servicemix.jbi.runtime.impl.ServiceEndpointImpl@c98337
      javax.jbi.messaging.MessageExchange =
org.apache.servicemix.jbi.runtime.impl.InOutImpl@1c59048
      javax.jbi.messaging.sendSync = true
      javax.jbi.ServiceName = <null>
      org.apache.servicemix.correlationId =
71638a4e-918d-41ba-b689-830400e09efd
      javax.jbi.transaction.jta = <null>
      javax.jbi.InterfaceName = <null>
      org.apache.servicemix.senderEndpoint = {
http://activemq.apache.org/camel/schema/jbi}consumer:ID:10.5.2.57-121c439d8f8-2:0
  ]
  In: [
    content:
org.apache.camel.converter.stream.StreamCacheConverter$StreamSourceCache@1837e72
  ]
]


10:42:39,133 | DEBUG | x-camel-thread-3 | DefaultExceptionPolicyStrategy   |
y.DefaultExceptionPolicyStrategy   77 | Finding best suited exception policy
for thrown exception java.lang.NullPointerException

10:42:39,133 | DEBUG | x-camel-thread-3 | DefaultExceptionPolicyStrategy   |
y.DefaultExceptionPolicyStrategy  125 | No candidate found to be used as
exception policy

10:42:39,133 | ERROR | x-camel-thread-3 | DeadLetterChannel                |
rg.apache.camel.processor.Logger  203 | Failed delivery for exchangeId:
ID-EnolanD820/1044-1244537675440/0-1. On delivery attempt: 0 caught:
java.lang.NullPointerException

java.lang.NullPointerException

    at
java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:846)

    at
org.apache.servicemix.jbi.deployer.artifacts.AssemblyReferencesListener.pending(AssemblyReferencesListener.java:117)

    at
org.apache.servicemix.jbi.deployer.artifacts.AssemblyReferencesListener.exchangeSent(AssemblyReferencesListener.java:99)

    at
org.apache.servicemix.nmr.core.ChannelImpl.dispatch(ChannelImpl.java:282)

    at
org.apache.servicemix.nmr.core.ChannelImpl.sendSync(ChannelImpl.java:141)

    at
org.apache.servicemix.nmr.core.ChannelImpl.sendSync(ChannelImpl.java:127)

    at
org.apache.servicemix.jbi.runtime.impl.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:189)

    at
org.apache.servicemix.common.EndpointDeliveryChannel.sendSync(EndpointDeliveryChannel.java:120)

    at
org.apache.servicemix.common.endpoints.SimpleEndpoint.sendSync(SimpleEndpoint.java:74)

    at
org.apache.servicemix.camel.CamelConsumerEndpoint.process(CamelConsumerEndpoint.java:112)

    at
org.apache.servicemix.camel.JbiEndpoint$JbiProducer.process(JbiEndpoint.java:94)

    at
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:69)

    at
org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:50)

    at
org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:50)

    at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:80)

    at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:189)

    at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133)

    at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)

    at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)

    at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)

    at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)

    at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)

    at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)

    at
org.apache.servicemix.camel.CamelProviderEndpoint.handleActiveProviderExchange(CamelProviderEndpoint.java:115)

    at
org.apache.servicemix.camel.CamelProviderEndpoint.process(CamelProviderEndpoint.java:73)

    at
org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:627)

    at
org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:581)

    at
org.apache.servicemix.common.AsyncBaseLifeCycle.processExchangeInTx(AsyncBaseLifeCycle.java:478)

    at
org.apache.servicemix.common.AsyncBaseLifeCycle$2.run(AsyncBaseLifeCycle.java:347)

    at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)

    at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)

    at java.lang.Thread.run(Thread.java:595)



On Mon, Jun 8, 2009 at 9:52 PM, Guillaume Nodet <[hidden email]> wrote:

> The NMR endpoints are now registered with either an INTERNAL_ENDPOINT
> property or an EXTERNAL_ENDPOINT property set to true.
> So this means we could add this property the props variable in order
> to select the right endpoint.
> The next question is: do we know if the target endpoint is an internal
> endpoint or an external endpoint ?
> A new test case inside jbi/itests would be nice for that.
>
> Anyway, I'm not so sure it will actually affect the routing.
> In this bit of code, the goal is to find the channel corresponding to
> the endpoint, but if it's not found, it should use the channel for the
> component itself, which should still work.
>
> Could you paste the stack trace of the NPE you had ?  Maybe this one
> should be fixed instead.
>
> On Mon, Jun 8, 2009 at 19:06, Edell Nolan<[hidden email]> wrote:
> > Hi,
> >
> > I am trying to run a demo against the latest kit but I seem to have hit
> an
> > issue in the
> >
> > org.apache.servicemix.jbi.runtime.impl.DeliveryChannelImpl =>
> >
> > In the getChannelToUse there is a note about a TODO - I seem to have a
> case
> > where I have an internal and external endpoint
> > that have the same service name and endpoint name.
> >
> > the basic sequence of events of the demo is as follows
> >
> > I have an external service that submits a request using soap/http to a
> > service thats deployed in smx from there it is routed through a few
> services
> > based on content etc and eventually uses a CBR service based on content
> to
> > make an external call using soap/http to an another external service.
> >
> > In the first attempt to make the call from the external service to the
> > service deployed within servicemix after debugging this code It has two
> > matching endpoints and as seen below none of them gets set so I end up
> with
> > a Null pointer exception in AssemblyReferencesListener due to no assembly
> > but its because the channel is wrong.
> >
> > If I force the below to use one of the matching endpoints then I can
> proceed
> > with my call going into myService but when it attempts to make an
> external
> > call back out I end up with no match and again the channel is wrong and
> > falls over with a Null pointer Exception.
> >
> > Is there a way I can get around this ?
> >
> > thanks, Edell.
> >
> >
> > protected Channel getChannelToUse(InternalExchange exchange) {
> >        Channel channelToUse = channel;
> >        if (exchange.getSource() == null) {
> >            // We need to look up the channel corresponding to the sender
> > endpoint
> >            try {
> >                String sender = (String)
> > exchange.getProperty(SENDER_ENDPOINT);
> >                if (sender != null) {
> >                    int idx = sender.lastIndexOf(':');
> >                    String svc = sender.substring(0, idx);
> >                    String ep = sender.substring(idx + 1);
> >                    Map<String, Object> props =
> > ServiceHelper.createMap(Endpoint.SERVICE_NAME, svc,
> >
> > Endpoint.ENDPOINT_NAME, ep);
> >                    // TODO: we may be using the wrong channel if both an
> > internal endpoint and an external endpoint
> >                    // have been registered with the same svc / ep name
> >                    List<Endpoint> eps =
> > channel.getNMR().getEndpointRegistry().query(props);
> >                    if (eps != null && eps.size() == 1) {
> >                        channelToUse = ((InternalEndpoint)
> > eps.get(0)).getChannel();
> >                    }
> >                }
> >            } catch (Throwable t) {
> >                // Ignore
> >            }
> >        } else {
> >            channelToUse = exchange.getSource().getChannel();
> >        }
> >        return channelToUse;
> >    }
> >
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>
Reply | Threaded
Open this post in threaded view
|

Re: Incorrect channel is set in the NMR

gertv
Edell,

I think you just bumped into
https://issues.apache.org/activemq/browse/SMX4NMR-136, which got fixed
last week.  Could you try with a more recent snapshot?

Regards,

Gert Vanthienen
------------------------
Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/



2009/6/9 Edell Nolan <[hidden email]>:

> included is my stackTrace
>
>
> I get the following error from a CBRService - it has picked the correct
> external service
>
> The following is from my xbean.xml file of my cbrService
>
> <camelContext xmlns="http://activemq.apache.org/camel/schema/spring"
>              xmlns:logisticx="http://logisticx.demo.fuse.iona.com/"
>              xmlns:ns1="
> http://logisticx.demo.fuse.iona.com/warehouseService/">
>
>    <route>
>      <from
>              uri="jbi:endpoint:
> http://logisticx.demo.fuse.iona.com//cbrService/cbrEndpoint"/>
>
>          <choice>
>            <when>
>              <xpath>/ns1:inStock/arg0/lineItem/itemId/text() =
> '1002'</xpath>
>              <to
>                      uri="jbi:endpoint:
> http://logisticx.demo.fuse.iona.com/warehouseService//WarehouseService/WarehouseEndpoint?mep=in-out,operation=http://logisticx.demo.fuse.iona.com/warehouseService/:instock"/>
>
>            </when>
>
>     .................
>
> </camelContext>
>
> then I have a cxfbc:provider which has
>
>    <cxfbc:provider service="ware:WarehouseService"
>        endpoint="WarehouseEndpoint" useJBIWrapper="false"
>            wsdl="classpath:warehouse.wsdl"
>        locationURI="http://localhost:8080/warehouse/services/warehouse"/>
>
>
> 10:42:39,133 | DEBUG | x-camel-thread-3 | NMR                              |
> .servicemix.nmr.core.ChannelImpl  274 | Channel
> org.apache.servicemix.nmr.core.ChannelImpl@f96093 dispatching exchange: [
>  id:        884874dd-e7e7-4357-8fb5-6765c12974fb
>  mep:       InOut
>  status:    Active
>  role:      Consumer
>  target:    PropertyMatchingReference[{SERVICE_NAME={
> http://logisticx.demo.fuse.iona.com/warehouseService/}WarehouseService,
> ENDPOINT_NAME=WarehouseEndpoint}]
>  operation: {http://logisticx.demo.fuse.iona.com/warehouseService/}inStock
>  properties: [
>      javax.jbi.ServiceEndpoint =
> org.apache.servicemix.jbi.runtime.impl.ServiceEndpointImpl@c98337
>      javax.jbi.messaging.MessageExchange =
> org.apache.servicemix.jbi.runtime.impl.InOutImpl@1c59048
>      javax.jbi.messaging.sendSync = true
>      javax.jbi.ServiceName = <null>
>      org.apache.servicemix.correlationId =
> 71638a4e-918d-41ba-b689-830400e09efd
>      javax.jbi.transaction.jta = <null>
>      javax.jbi.InterfaceName = <null>
>      org.apache.servicemix.senderEndpoint = {
> http://activemq.apache.org/camel/schema/jbi}consumer:ID:10.5.2.57-121c439d8f8-2:0
>  ]
>  In: [
>    content:
> org.apache.camel.converter.stream.StreamCacheConverter$StreamSourceCache@1837e72
>  ]
> ]
>
>
> 10:42:39,133 | DEBUG | x-camel-thread-3 | DefaultExceptionPolicyStrategy   |
> y.DefaultExceptionPolicyStrategy   77 | Finding best suited exception policy
> for thrown exception java.lang.NullPointerException
>
> 10:42:39,133 | DEBUG | x-camel-thread-3 | DefaultExceptionPolicyStrategy   |
> y.DefaultExceptionPolicyStrategy  125 | No candidate found to be used as
> exception policy
>
> 10:42:39,133 | ERROR | x-camel-thread-3 | DeadLetterChannel                |
> rg.apache.camel.processor.Logger  203 | Failed delivery for exchangeId:
> ID-EnolanD820/1044-1244537675440/0-1. On delivery attempt: 0 caught:
> java.lang.NullPointerException
>
> java.lang.NullPointerException
>
>    at
> java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:846)
>
>    at
> org.apache.servicemix.jbi.deployer.artifacts.AssemblyReferencesListener.pending(AssemblyReferencesListener.java:117)
>
>    at
> org.apache.servicemix.jbi.deployer.artifacts.AssemblyReferencesListener.exchangeSent(AssemblyReferencesListener.java:99)
>
>    at
> org.apache.servicemix.nmr.core.ChannelImpl.dispatch(ChannelImpl.java:282)
>
>    at
> org.apache.servicemix.nmr.core.ChannelImpl.sendSync(ChannelImpl.java:141)
>
>    at
> org.apache.servicemix.nmr.core.ChannelImpl.sendSync(ChannelImpl.java:127)
>
>    at
> org.apache.servicemix.jbi.runtime.impl.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:189)
>
>    at
> org.apache.servicemix.common.EndpointDeliveryChannel.sendSync(EndpointDeliveryChannel.java:120)
>
>    at
> org.apache.servicemix.common.endpoints.SimpleEndpoint.sendSync(SimpleEndpoint.java:74)
>
>    at
> org.apache.servicemix.camel.CamelConsumerEndpoint.process(CamelConsumerEndpoint.java:112)
>
>    at
> org.apache.servicemix.camel.JbiEndpoint$JbiProducer.process(JbiEndpoint.java:94)
>
>    at
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:69)
>
>    at
> org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:50)
>
>    at
> org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:50)
>
>    at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:80)
>
>    at
> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:189)
>
>    at
> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133)
>
>    at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
>
>    at
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
>
>    at
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
>
>    at
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
>
>    at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>
>    at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>
>    at
> org.apache.servicemix.camel.CamelProviderEndpoint.handleActiveProviderExchange(CamelProviderEndpoint.java:115)
>
>    at
> org.apache.servicemix.camel.CamelProviderEndpoint.process(CamelProviderEndpoint.java:73)
>
>    at
> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:627)
>
>    at
> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:581)
>
>    at
> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchangeInTx(AsyncBaseLifeCycle.java:478)
>
>    at
> org.apache.servicemix.common.AsyncBaseLifeCycle$2.run(AsyncBaseLifeCycle.java:347)
>
>    at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
>
>    at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
>
>    at java.lang.Thread.run(Thread.java:595)
>
>
>
> On Mon, Jun 8, 2009 at 9:52 PM, Guillaume Nodet <[hidden email]> wrote:
>
>> The NMR endpoints are now registered with either an INTERNAL_ENDPOINT
>> property or an EXTERNAL_ENDPOINT property set to true.
>> So this means we could add this property the props variable in order
>> to select the right endpoint.
>> The next question is: do we know if the target endpoint is an internal
>> endpoint or an external endpoint ?
>> A new test case inside jbi/itests would be nice for that.
>>
>> Anyway, I'm not so sure it will actually affect the routing.
>> In this bit of code, the goal is to find the channel corresponding to
>> the endpoint, but if it's not found, it should use the channel for the
>> component itself, which should still work.
>>
>> Could you paste the stack trace of the NPE you had ?  Maybe this one
>> should be fixed instead.
>>
>> On Mon, Jun 8, 2009 at 19:06, Edell Nolan<[hidden email]> wrote:
>> > Hi,
>> >
>> > I am trying to run a demo against the latest kit but I seem to have hit
>> an
>> > issue in the
>> >
>> > org.apache.servicemix.jbi.runtime.impl.DeliveryChannelImpl =>
>> >
>> > In the getChannelToUse there is a note about a TODO - I seem to have a
>> case
>> > where I have an internal and external endpoint
>> > that have the same service name and endpoint name.
>> >
>> > the basic sequence of events of the demo is as follows
>> >
>> > I have an external service that submits a request using soap/http to a
>> > service thats deployed in smx from there it is routed through a few
>> services
>> > based on content etc and eventually uses a CBR service based on content
>> to
>> > make an external call using soap/http to an another external service.
>> >
>> > In the first attempt to make the call from the external service to the
>> > service deployed within servicemix after debugging this code It has two
>> > matching endpoints and as seen below none of them gets set so I end up
>> with
>> > a Null pointer exception in AssemblyReferencesListener due to no assembly
>> > but its because the channel is wrong.
>> >
>> > If I force the below to use one of the matching endpoints then I can
>> proceed
>> > with my call going into myService but when it attempts to make an
>> external
>> > call back out I end up with no match and again the channel is wrong and
>> > falls over with a Null pointer Exception.
>> >
>> > Is there a way I can get around this ?
>> >
>> > thanks, Edell.
>> >
>> >
>> > protected Channel getChannelToUse(InternalExchange exchange) {
>> >        Channel channelToUse = channel;
>> >        if (exchange.getSource() == null) {
>> >            // We need to look up the channel corresponding to the sender
>> > endpoint
>> >            try {
>> >                String sender = (String)
>> > exchange.getProperty(SENDER_ENDPOINT);
>> >                if (sender != null) {
>> >                    int idx = sender.lastIndexOf(':');
>> >                    String svc = sender.substring(0, idx);
>> >                    String ep = sender.substring(idx + 1);
>> >                    Map<String, Object> props =
>> > ServiceHelper.createMap(Endpoint.SERVICE_NAME, svc,
>> >
>> > Endpoint.ENDPOINT_NAME, ep);
>> >                    // TODO: we may be using the wrong channel if both an
>> > internal endpoint and an external endpoint
>> >                    // have been registered with the same svc / ep name
>> >                    List<Endpoint> eps =
>> > channel.getNMR().getEndpointRegistry().query(props);
>> >                    if (eps != null && eps.size() == 1) {
>> >                        channelToUse = ((InternalEndpoint)
>> > eps.get(0)).getChannel();
>> >                    }
>> >                }
>> >            } catch (Throwable t) {
>> >                // Ignore
>> >            }
>> >        } else {
>> >            channelToUse = exchange.getSource().getChannel();
>> >        }
>> >        return channelToUse;
>> >    }
>> >
>>
>>
>>
>> --
>> Cheers,
>> Guillaume Nodet
>> ------------------------
>> Blog: http://gnodet.blogspot.com/
>> ------------------------
>> Open Source SOA
>> http://fusesource.com
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Incorrect channel is set in the NMR

Edell Nolan
thanks will give that a go

On Tue, Jun 9, 2009 at 11:02 AM, Gert Vanthienen
<[hidden email]>wrote:

> Edell,
>
> I think you just bumped into
> https://issues.apache.org/activemq/browse/SMX4NMR-136, which got fixed
> last week.  Could you try with a more recent snapshot?
>
> Regards,
>
> Gert Vanthienen
> ------------------------
> Open Source SOA: http://fusesource.com
> Blog: http://gertvanthienen.blogspot.com/
>
>
>
> 2009/6/9 Edell Nolan <[hidden email]>:
> > included is my stackTrace
> >
> >
> > I get the following error from a CBRService - it has picked the correct
> > external service
> >
> > The following is from my xbean.xml file of my cbrService
> >
> > <camelContext xmlns="http://activemq.apache.org/camel/schema/spring"
> >              xmlns:logisticx="http://logisticx.demo.fuse.iona.com/"
> >              xmlns:ns1="
> > http://logisticx.demo.fuse.iona.com/warehouseService/">
> >
> >    <route>
> >      <from
> >              uri="jbi:endpoint:
> > http://logisticx.demo.fuse.iona.com//cbrService/cbrEndpoint"/>
> >
> >          <choice>
> >            <when>
> >              <xpath>/ns1:inStock/arg0/lineItem/itemId/text() =
> > '1002'</xpath>
> >              <to
> >                      uri="jbi:endpoint:
> >
> http://logisticx.demo.fuse.iona.com/warehouseService//WarehouseService/WarehouseEndpoint?mep=in-out,operation=http://logisticx.demo.fuse.iona.com/warehouseService/:instock
> "/>
> >
> >            </when>
> >
> >     .................
> >
> > </camelContext>
> >
> > then I have a cxfbc:provider which has
> >
> >    <cxfbc:provider service="ware:WarehouseService"
> >        endpoint="WarehouseEndpoint" useJBIWrapper="false"
> >            wsdl="classpath:warehouse.wsdl"
> >        locationURI="http://localhost:8080/warehouse/services/warehouse
> "/>
> >
> >
> > 10:42:39,133 | DEBUG | x-camel-thread-3 | NMR
>  |
> > .servicemix.nmr.core.ChannelImpl  274 | Channel
> > org.apache.servicemix.nmr.core.ChannelImpl@f96093 dispatching exchange:
> [
> >  id:        884874dd-e7e7-4357-8fb5-6765c12974fb
> >  mep:       InOut
> >  status:    Active
> >  role:      Consumer
> >  target:    PropertyMatchingReference[{SERVICE_NAME={
> > http://logisticx.demo.fuse.iona.com/warehouseService/}WarehouseService<http://logisticx.demo.fuse.iona.com/warehouseService/%7DWarehouseService>
> ,
> > ENDPOINT_NAME=WarehouseEndpoint}]
> >  operation: {
> http://logisticx.demo.fuse.iona.com/warehouseService/}inStock<http://logisticx.demo.fuse.iona.com/warehouseService/%7DinStock>
> >  properties: [
> >      javax.jbi.ServiceEndpoint =
> > org.apache.servicemix.jbi.runtime.impl.ServiceEndpointImpl@c98337
> >      javax.jbi.messaging.MessageExchange =
> > org.apache.servicemix.jbi.runtime.impl.InOutImpl@1c59048
> >      javax.jbi.messaging.sendSync = true
> >      javax.jbi.ServiceName = <null>
> >      org.apache.servicemix.correlationId =
> > 71638a4e-918d-41ba-b689-830400e09efd
> >      javax.jbi.transaction.jta = <null>
> >      javax.jbi.InterfaceName = <null>
> >      org.apache.servicemix.senderEndpoint = {
> >
> http://activemq.apache.org/camel/schema/jbi}consumer:ID:10.5.2.57-121c439d8f8-2:0<http://activemq.apache.org/camel/schema/jbi%7Dconsumer:ID:10.5.2.57-121c439d8f8-2:0>
> >  ]
> >  In: [
> >    content:
> >
> org.apache.camel.converter.stream.StreamCacheConverter$StreamSourceCache@1837e72
> >  ]
> > ]
> >
> >
> > 10:42:39,133 | DEBUG | x-camel-thread-3 | DefaultExceptionPolicyStrategy
>   |
> > y.DefaultExceptionPolicyStrategy   77 | Finding best suited exception
> policy
> > for thrown exception java.lang.NullPointerException
> >
> > 10:42:39,133 | DEBUG | x-camel-thread-3 | DefaultExceptionPolicyStrategy
>   |
> > y.DefaultExceptionPolicyStrategy  125 | No candidate found to be used as
> > exception policy
> >
> > 10:42:39,133 | ERROR | x-camel-thread-3 | DeadLetterChannel
>  |
> > rg.apache.camel.processor.Logger  203 | Failed delivery for exchangeId:
> > ID-EnolanD820/1044-1244537675440/0-1. On delivery attempt: 0 caught:
> > java.lang.NullPointerException
> >
> > java.lang.NullPointerException
> >
> >    at
> > java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:846)
> >
> >    at
> >
> org.apache.servicemix.jbi.deployer.artifacts.AssemblyReferencesListener.pending(AssemblyReferencesListener.java:117)
> >
> >    at
> >
> org.apache.servicemix.jbi.deployer.artifacts.AssemblyReferencesListener.exchangeSent(AssemblyReferencesListener.java:99)
> >
> >    at
> > org.apache.servicemix.nmr.core.ChannelImpl.dispatch(ChannelImpl.java:282)
> >
> >    at
> > org.apache.servicemix.nmr.core.ChannelImpl.sendSync(ChannelImpl.java:141)
> >
> >    at
> > org.apache.servicemix.nmr.core.ChannelImpl.sendSync(ChannelImpl.java:127)
> >
> >    at
> >
> org.apache.servicemix.jbi.runtime.impl.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:189)
> >
> >    at
> >
> org.apache.servicemix.common.EndpointDeliveryChannel.sendSync(EndpointDeliveryChannel.java:120)
> >
> >    at
> >
> org.apache.servicemix.common.endpoints.SimpleEndpoint.sendSync(SimpleEndpoint.java:74)
> >
> >    at
> >
> org.apache.servicemix.camel.CamelConsumerEndpoint.process(CamelConsumerEndpoint.java:112)
> >
> >    at
> >
> org.apache.servicemix.camel.JbiEndpoint$JbiProducer.process(JbiEndpoint.java:94)
> >
> >    at
> > org.apache.camel.processor.SendProcessor.process(SendProcessor.java:69)
> >
> >    at
> >
> org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:50)
> >
> >    at
> >
> org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:50)
> >
> >    at
> >
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:80)
> >
> >    at
> >
> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:189)
> >
> >    at
> >
> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133)
> >
> >    at
> >
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
> >
> >    at
> >
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
> >
> >    at
> >
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
> >
> >    at
> >
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
> >
> >    at
> >
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
> >
> >    at
> >
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
> >
> >    at
> >
> org.apache.servicemix.camel.CamelProviderEndpoint.handleActiveProviderExchange(CamelProviderEndpoint.java:115)
> >
> >    at
> >
> org.apache.servicemix.camel.CamelProviderEndpoint.process(CamelProviderEndpoint.java:73)
> >
> >    at
> >
> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:627)
> >
> >    at
> >
> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:581)
> >
> >    at
> >
> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchangeInTx(AsyncBaseLifeCycle.java:478)
> >
> >    at
> >
> org.apache.servicemix.common.AsyncBaseLifeCycle$2.run(AsyncBaseLifeCycle.java:347)
> >
> >    at
> >
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
> >
> >    at
> >
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
> >
> >    at java.lang.Thread.run(Thread.java:595)
> >
> >
> >
> > On Mon, Jun 8, 2009 at 9:52 PM, Guillaume Nodet <[hidden email]>
> wrote:
> >
> >> The NMR endpoints are now registered with either an INTERNAL_ENDPOINT
> >> property or an EXTERNAL_ENDPOINT property set to true.
> >> So this means we could add this property the props variable in order
> >> to select the right endpoint.
> >> The next question is: do we know if the target endpoint is an internal
> >> endpoint or an external endpoint ?
> >> A new test case inside jbi/itests would be nice for that.
> >>
> >> Anyway, I'm not so sure it will actually affect the routing.
> >> In this bit of code, the goal is to find the channel corresponding to
> >> the endpoint, but if it's not found, it should use the channel for the
> >> component itself, which should still work.
> >>
> >> Could you paste the stack trace of the NPE you had ?  Maybe this one
> >> should be fixed instead.
> >>
> >> On Mon, Jun 8, 2009 at 19:06, Edell Nolan<[hidden email]> wrote:
> >> > Hi,
> >> >
> >> > I am trying to run a demo against the latest kit but I seem to have
> hit
> >> an
> >> > issue in the
> >> >
> >> > org.apache.servicemix.jbi.runtime.impl.DeliveryChannelImpl =>
> >> >
> >> > In the getChannelToUse there is a note about a TODO - I seem to have a
> >> case
> >> > where I have an internal and external endpoint
> >> > that have the same service name and endpoint name.
> >> >
> >> > the basic sequence of events of the demo is as follows
> >> >
> >> > I have an external service that submits a request using soap/http to a
> >> > service thats deployed in smx from there it is routed through a few
> >> services
> >> > based on content etc and eventually uses a CBR service based on
> content
> >> to
> >> > make an external call using soap/http to an another external service.
> >> >
> >> > In the first attempt to make the call from the external service to the
> >> > service deployed within servicemix after debugging this code It has
> two
> >> > matching endpoints and as seen below none of them gets set so I end up
> >> with
> >> > a Null pointer exception in AssemblyReferencesListener due to no
> assembly
> >> > but its because the channel is wrong.
> >> >
> >> > If I force the below to use one of the matching endpoints then I can
> >> proceed
> >> > with my call going into myService but when it attempts to make an
> >> external
> >> > call back out I end up with no match and again the channel is wrong
> and
> >> > falls over with a Null pointer Exception.
> >> >
> >> > Is there a way I can get around this ?
> >> >
> >> > thanks, Edell.
> >> >
> >> >
> >> > protected Channel getChannelToUse(InternalExchange exchange) {
> >> >        Channel channelToUse = channel;
> >> >        if (exchange.getSource() == null) {
> >> >            // We need to look up the channel corresponding to the
> sender
> >> > endpoint
> >> >            try {
> >> >                String sender = (String)
> >> > exchange.getProperty(SENDER_ENDPOINT);
> >> >                if (sender != null) {
> >> >                    int idx = sender.lastIndexOf(':');
> >> >                    String svc = sender.substring(0, idx);
> >> >                    String ep = sender.substring(idx + 1);
> >> >                    Map<String, Object> props =
> >> > ServiceHelper.createMap(Endpoint.SERVICE_NAME, svc,
> >> >
> >> > Endpoint.ENDPOINT_NAME, ep);
> >> >                    // TODO: we may be using the wrong channel if both
> an
> >> > internal endpoint and an external endpoint
> >> >                    // have been registered with the same svc / ep name
> >> >                    List<Endpoint> eps =
> >> > channel.getNMR().getEndpointRegistry().query(props);
> >> >                    if (eps != null && eps.size() == 1) {
> >> >                        channelToUse = ((InternalEndpoint)
> >> > eps.get(0)).getChannel();
> >> >                    }
> >> >                }
> >> >            } catch (Throwable t) {
> >> >                // Ignore
> >> >            }
> >> >        } else {
> >> >            channelToUse = exchange.getSource().getChannel();
> >> >        }
> >> >        return channelToUse;
> >> >    }
> >> >
> >>
> >>
> >>
> >> --
> >> Cheers,
> >> Guillaume Nodet
> >> ------------------------
> >> Blog: http://gnodet.blogspot.com/
> >> ------------------------
> >> Open Source SOA
> >> http://fusesource.com
> >>
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Incorrect channel is set in the NMR

Guillaume Nodet
Administrator
In reply to this post by gertv
Yeah, I was looking at the current code and could not understand how
this NPE could happen.

On Tue, Jun 9, 2009 at 12:02, Gert Vanthienen<[hidden email]> wrote:

> Edell,
>
> I think you just bumped into
> https://issues.apache.org/activemq/browse/SMX4NMR-136, which got fixed
> last week.  Could you try with a more recent snapshot?
>
> Regards,
>
> Gert Vanthienen
> ------------------------
> Open Source SOA: http://fusesource.com
> Blog: http://gertvanthienen.blogspot.com/
>
>
>
> 2009/6/9 Edell Nolan <[hidden email]>:
>> included is my stackTrace
>>
>>
>> I get the following error from a CBRService - it has picked the correct
>> external service
>>
>> The following is from my xbean.xml file of my cbrService
>>
>> <camelContext xmlns="http://activemq.apache.org/camel/schema/spring"
>>              xmlns:logisticx="http://logisticx.demo.fuse.iona.com/"
>>              xmlns:ns1="
>> http://logisticx.demo.fuse.iona.com/warehouseService/">
>>
>>    <route>
>>      <from
>>              uri="jbi:endpoint:
>> http://logisticx.demo.fuse.iona.com//cbrService/cbrEndpoint"/>
>>
>>          <choice>
>>            <when>
>>              <xpath>/ns1:inStock/arg0/lineItem/itemId/text() =
>> '1002'</xpath>
>>              <to
>>                      uri="jbi:endpoint:
>> http://logisticx.demo.fuse.iona.com/warehouseService//WarehouseService/WarehouseEndpoint?mep=in-out,operation=http://logisticx.demo.fuse.iona.com/warehouseService/:instock"/>
>>
>>            </when>
>>
>>     .................
>>
>> </camelContext>
>>
>> then I have a cxfbc:provider which has
>>
>>    <cxfbc:provider service="ware:WarehouseService"
>>        endpoint="WarehouseEndpoint" useJBIWrapper="false"
>>            wsdl="classpath:warehouse.wsdl"
>>        locationURI="http://localhost:8080/warehouse/services/warehouse"/>
>>
>>
>> 10:42:39,133 | DEBUG | x-camel-thread-3 | NMR                              |
>> .servicemix.nmr.core.ChannelImpl  274 | Channel
>> org.apache.servicemix.nmr.core.ChannelImpl@f96093 dispatching exchange: [
>>  id:        884874dd-e7e7-4357-8fb5-6765c12974fb
>>  mep:       InOut
>>  status:    Active
>>  role:      Consumer
>>  target:    PropertyMatchingReference[{SERVICE_NAME={
>> http://logisticx.demo.fuse.iona.com/warehouseService/}WarehouseService,
>> ENDPOINT_NAME=WarehouseEndpoint}]
>>  operation: {http://logisticx.demo.fuse.iona.com/warehouseService/}inStock
>>  properties: [
>>      javax.jbi.ServiceEndpoint =
>> org.apache.servicemix.jbi.runtime.impl.ServiceEndpointImpl@c98337
>>      javax.jbi.messaging.MessageExchange =
>> org.apache.servicemix.jbi.runtime.impl.InOutImpl@1c59048
>>      javax.jbi.messaging.sendSync = true
>>      javax.jbi.ServiceName = <null>
>>      org.apache.servicemix.correlationId =
>> 71638a4e-918d-41ba-b689-830400e09efd
>>      javax.jbi.transaction.jta = <null>
>>      javax.jbi.InterfaceName = <null>
>>      org.apache.servicemix.senderEndpoint = {
>> http://activemq.apache.org/camel/schema/jbi}consumer:ID:10.5.2.57-121c439d8f8-2:0
>>  ]
>>  In: [
>>    content:
>> org.apache.camel.converter.stream.StreamCacheConverter$StreamSourceCache@1837e72
>>  ]
>> ]
>>
>>
>> 10:42:39,133 | DEBUG | x-camel-thread-3 | DefaultExceptionPolicyStrategy   |
>> y.DefaultExceptionPolicyStrategy   77 | Finding best suited exception policy
>> for thrown exception java.lang.NullPointerException
>>
>> 10:42:39,133 | DEBUG | x-camel-thread-3 | DefaultExceptionPolicyStrategy   |
>> y.DefaultExceptionPolicyStrategy  125 | No candidate found to be used as
>> exception policy
>>
>> 10:42:39,133 | ERROR | x-camel-thread-3 | DeadLetterChannel                |
>> rg.apache.camel.processor.Logger  203 | Failed delivery for exchangeId:
>> ID-EnolanD820/1044-1244537675440/0-1. On delivery attempt: 0 caught:
>> java.lang.NullPointerException
>>
>> java.lang.NullPointerException
>>
>>    at
>> java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:846)
>>
>>    at
>> org.apache.servicemix.jbi.deployer.artifacts.AssemblyReferencesListener.pending(AssemblyReferencesListener.java:117)
>>
>>    at
>> org.apache.servicemix.jbi.deployer.artifacts.AssemblyReferencesListener.exchangeSent(AssemblyReferencesListener.java:99)
>>
>>    at
>> org.apache.servicemix.nmr.core.ChannelImpl.dispatch(ChannelImpl.java:282)
>>
>>    at
>> org.apache.servicemix.nmr.core.ChannelImpl.sendSync(ChannelImpl.java:141)
>>
>>    at
>> org.apache.servicemix.nmr.core.ChannelImpl.sendSync(ChannelImpl.java:127)
>>
>>    at
>> org.apache.servicemix.jbi.runtime.impl.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:189)
>>
>>    at
>> org.apache.servicemix.common.EndpointDeliveryChannel.sendSync(EndpointDeliveryChannel.java:120)
>>
>>    at
>> org.apache.servicemix.common.endpoints.SimpleEndpoint.sendSync(SimpleEndpoint.java:74)
>>
>>    at
>> org.apache.servicemix.camel.CamelConsumerEndpoint.process(CamelConsumerEndpoint.java:112)
>>
>>    at
>> org.apache.servicemix.camel.JbiEndpoint$JbiProducer.process(JbiEndpoint.java:94)
>>
>>    at
>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:69)
>>
>>    at
>> org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:50)
>>
>>    at
>> org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:50)
>>
>>    at
>> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:80)
>>
>>    at
>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:189)
>>
>>    at
>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133)
>>
>>    at
>> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
>>
>>    at
>> org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
>>
>>    at
>> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
>>
>>    at
>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
>>
>>    at
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>>
>>    at
>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>>
>>    at
>> org.apache.servicemix.camel.CamelProviderEndpoint.handleActiveProviderExchange(CamelProviderEndpoint.java:115)
>>
>>    at
>> org.apache.servicemix.camel.CamelProviderEndpoint.process(CamelProviderEndpoint.java:73)
>>
>>    at
>> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:627)
>>
>>    at
>> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:581)
>>
>>    at
>> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchangeInTx(AsyncBaseLifeCycle.java:478)
>>
>>    at
>> org.apache.servicemix.common.AsyncBaseLifeCycle$2.run(AsyncBaseLifeCycle.java:347)
>>
>>    at
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
>>
>>    at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
>>
>>    at java.lang.Thread.run(Thread.java:595)
>>
>>
>>
>> On Mon, Jun 8, 2009 at 9:52 PM, Guillaume Nodet <[hidden email]> wrote:
>>
>>> The NMR endpoints are now registered with either an INTERNAL_ENDPOINT
>>> property or an EXTERNAL_ENDPOINT property set to true.
>>> So this means we could add this property the props variable in order
>>> to select the right endpoint.
>>> The next question is: do we know if the target endpoint is an internal
>>> endpoint or an external endpoint ?
>>> A new test case inside jbi/itests would be nice for that.
>>>
>>> Anyway, I'm not so sure it will actually affect the routing.
>>> In this bit of code, the goal is to find the channel corresponding to
>>> the endpoint, but if it's not found, it should use the channel for the
>>> component itself, which should still work.
>>>
>>> Could you paste the stack trace of the NPE you had ?  Maybe this one
>>> should be fixed instead.
>>>
>>> On Mon, Jun 8, 2009 at 19:06, Edell Nolan<[hidden email]> wrote:
>>> > Hi,
>>> >
>>> > I am trying to run a demo against the latest kit but I seem to have hit
>>> an
>>> > issue in the
>>> >
>>> > org.apache.servicemix.jbi.runtime.impl.DeliveryChannelImpl =>
>>> >
>>> > In the getChannelToUse there is a note about a TODO - I seem to have a
>>> case
>>> > where I have an internal and external endpoint
>>> > that have the same service name and endpoint name.
>>> >
>>> > the basic sequence of events of the demo is as follows
>>> >
>>> > I have an external service that submits a request using soap/http to a
>>> > service thats deployed in smx from there it is routed through a few
>>> services
>>> > based on content etc and eventually uses a CBR service based on content
>>> to
>>> > make an external call using soap/http to an another external service.
>>> >
>>> > In the first attempt to make the call from the external service to the
>>> > service deployed within servicemix after debugging this code It has two
>>> > matching endpoints and as seen below none of them gets set so I end up
>>> with
>>> > a Null pointer exception in AssemblyReferencesListener due to no assembly
>>> > but its because the channel is wrong.
>>> >
>>> > If I force the below to use one of the matching endpoints then I can
>>> proceed
>>> > with my call going into myService but when it attempts to make an
>>> external
>>> > call back out I end up with no match and again the channel is wrong and
>>> > falls over with a Null pointer Exception.
>>> >
>>> > Is there a way I can get around this ?
>>> >
>>> > thanks, Edell.
>>> >
>>> >
>>> > protected Channel getChannelToUse(InternalExchange exchange) {
>>> >        Channel channelToUse = channel;
>>> >        if (exchange.getSource() == null) {
>>> >            // We need to look up the channel corresponding to the sender
>>> > endpoint
>>> >            try {
>>> >                String sender = (String)
>>> > exchange.getProperty(SENDER_ENDPOINT);
>>> >                if (sender != null) {
>>> >                    int idx = sender.lastIndexOf(':');
>>> >                    String svc = sender.substring(0, idx);
>>> >                    String ep = sender.substring(idx + 1);
>>> >                    Map<String, Object> props =
>>> > ServiceHelper.createMap(Endpoint.SERVICE_NAME, svc,
>>> >
>>> > Endpoint.ENDPOINT_NAME, ep);
>>> >                    // TODO: we may be using the wrong channel if both an
>>> > internal endpoint and an external endpoint
>>> >                    // have been registered with the same svc / ep name
>>> >                    List<Endpoint> eps =
>>> > channel.getNMR().getEndpointRegistry().query(props);
>>> >                    if (eps != null && eps.size() == 1) {
>>> >                        channelToUse = ((InternalEndpoint)
>>> > eps.get(0)).getChannel();
>>> >                    }
>>> >                }
>>> >            } catch (Throwable t) {
>>> >                // Ignore
>>> >            }
>>> >        } else {
>>> >            channelToUse = exchange.getSource().getChannel();
>>> >        }
>>> >        return channelToUse;
>>> >    }
>>> >
>>>
>>>
>>>
>>> --
>>> Cheers,
>>> Guillaume Nodet
>>> ------------------------
>>> Blog: http://gnodet.blogspot.com/
>>> ------------------------
>>> Open Source SOA
>>> http://fusesource.com
>>>
>>
>



--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com
Reply | Threaded
Open this post in threaded view
|

Re: Incorrect channel is set in the NMR

Edell Nolan
In reply to this post by Edell Nolan
Yep! if i take those code changes - that fixes my issue - thanks, Edell.

On Tue, Jun 9, 2009 at 11:06 AM, Edell Nolan <[hidden email]> wrote:

> thanks will give that a go
>
>
> On Tue, Jun 9, 2009 at 11:02 AM, Gert Vanthienen <
> [hidden email]> wrote:
>
>> Edell,
>>
>> I think you just bumped into
>> https://issues.apache.org/activemq/browse/SMX4NMR-136, which got fixed
>> last week.  Could you try with a more recent snapshot?
>>
>> Regards,
>>
>> Gert Vanthienen
>> ------------------------
>> Open Source SOA: http://fusesource.com
>> Blog: http://gertvanthienen.blogspot.com/
>>
>>
>>
>> 2009/6/9 Edell Nolan <[hidden email]>:
>> > included is my stackTrace
>> >
>> >
>> > I get the following error from a CBRService - it has picked the correct
>> > external service
>> >
>> > The following is from my xbean.xml file of my cbrService
>> >
>> > <camelContext xmlns="http://activemq.apache.org/camel/schema/spring"
>> >              xmlns:logisticx="http://logisticx.demo.fuse.iona.com/"
>> >              xmlns:ns1="
>> > http://logisticx.demo.fuse.iona.com/warehouseService/">
>> >
>> >    <route>
>> >      <from
>> >              uri="jbi:endpoint:
>> > http://logisticx.demo.fuse.iona.com//cbrService/cbrEndpoint"/>
>> >
>> >          <choice>
>> >            <when>
>> >              <xpath>/ns1:inStock/arg0/lineItem/itemId/text() =
>> > '1002'</xpath>
>> >              <to
>> >                      uri="jbi:endpoint:
>> >
>> http://logisticx.demo.fuse.iona.com/warehouseService//WarehouseService/WarehouseEndpoint?mep=in-out,operation=http://logisticx.demo.fuse.iona.com/warehouseService/:instock
>> "/>
>> >
>> >            </when>
>> >
>> >     .................
>> >
>> > </camelContext>
>> >
>> > then I have a cxfbc:provider which has
>> >
>> >    <cxfbc:provider service="ware:WarehouseService"
>> >        endpoint="WarehouseEndpoint" useJBIWrapper="false"
>> >            wsdl="classpath:warehouse.wsdl"
>> >        locationURI="http://localhost:8080/warehouse/services/warehouse
>> "/>
>> >
>> >
>> > 10:42:39,133 | DEBUG | x-camel-thread-3 | NMR
>>    |
>> > .servicemix.nmr.core.ChannelImpl  274 | Channel
>> > org.apache.servicemix.nmr.core.ChannelImpl@f96093 dispatching exchange:
>> [
>> >  id:        884874dd-e7e7-4357-8fb5-6765c12974fb
>> >  mep:       InOut
>> >  status:    Active
>> >  role:      Consumer
>> >  target:    PropertyMatchingReference[{SERVICE_NAME={
>> > http://logisticx.demo.fuse.iona.com/warehouseService/}WarehouseService<http://logisticx.demo.fuse.iona.com/warehouseService/%7DWarehouseService>
>> ,
>> > ENDPOINT_NAME=WarehouseEndpoint}]
>> >  operation: {
>> http://logisticx.demo.fuse.iona.com/warehouseService/}inStock<http://logisticx.demo.fuse.iona.com/warehouseService/%7DinStock>
>> >  properties: [
>> >      javax.jbi.ServiceEndpoint =
>> > org.apache.servicemix.jbi.runtime.impl.ServiceEndpointImpl@c98337
>> >      javax.jbi.messaging.MessageExchange =
>> > org.apache.servicemix.jbi.runtime.impl.InOutImpl@1c59048
>> >      javax.jbi.messaging.sendSync = true
>> >      javax.jbi.ServiceName = <null>
>> >      org.apache.servicemix.correlationId =
>> > 71638a4e-918d-41ba-b689-830400e09efd
>> >      javax.jbi.transaction.jta = <null>
>> >      javax.jbi.InterfaceName = <null>
>> >      org.apache.servicemix.senderEndpoint = {
>> >
>> http://activemq.apache.org/camel/schema/jbi}consumer:ID:10.5.2.57-121c439d8f8-2:0<http://activemq.apache.org/camel/schema/jbi%7Dconsumer:ID:10.5.2.57-121c439d8f8-2:0>
>> >  ]
>> >  In: [
>> >    content:
>> >
>> org.apache.camel.converter.stream.StreamCacheConverter$StreamSourceCache@1837e72
>> >  ]
>> > ]
>> >
>> >
>> > 10:42:39,133 | DEBUG | x-camel-thread-3 | DefaultExceptionPolicyStrategy
>>   |
>> > y.DefaultExceptionPolicyStrategy   77 | Finding best suited exception
>> policy
>> > for thrown exception java.lang.NullPointerException
>> >
>> > 10:42:39,133 | DEBUG | x-camel-thread-3 | DefaultExceptionPolicyStrategy
>>   |
>> > y.DefaultExceptionPolicyStrategy  125 | No candidate found to be used as
>> > exception policy
>> >
>> > 10:42:39,133 | ERROR | x-camel-thread-3 | DeadLetterChannel
>>    |
>> > rg.apache.camel.processor.Logger  203 | Failed delivery for exchangeId:
>> > ID-EnolanD820/1044-1244537675440/0-1. On delivery attempt: 0 caught:
>> > java.lang.NullPointerException
>> >
>> > java.lang.NullPointerException
>> >
>> >    at
>> > java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:846)
>> >
>> >    at
>> >
>> org.apache.servicemix.jbi.deployer.artifacts.AssemblyReferencesListener.pending(AssemblyReferencesListener.java:117)
>> >
>> >    at
>> >
>> org.apache.servicemix.jbi.deployer.artifacts.AssemblyReferencesListener.exchangeSent(AssemblyReferencesListener.java:99)
>> >
>> >    at
>> >
>> org.apache.servicemix.nmr.core.ChannelImpl.dispatch(ChannelImpl.java:282)
>> >
>> >    at
>> >
>> org.apache.servicemix.nmr.core.ChannelImpl.sendSync(ChannelImpl.java:141)
>> >
>> >    at
>> >
>> org.apache.servicemix.nmr.core.ChannelImpl.sendSync(ChannelImpl.java:127)
>> >
>> >    at
>> >
>> org.apache.servicemix.jbi.runtime.impl.DeliveryChannelImpl.sendSync(DeliveryChannelImpl.java:189)
>> >
>> >    at
>> >
>> org.apache.servicemix.common.EndpointDeliveryChannel.sendSync(EndpointDeliveryChannel.java:120)
>> >
>> >    at
>> >
>> org.apache.servicemix.common.endpoints.SimpleEndpoint.sendSync(SimpleEndpoint.java:74)
>> >
>> >    at
>> >
>> org.apache.servicemix.camel.CamelConsumerEndpoint.process(CamelConsumerEndpoint.java:112)
>> >
>> >    at
>> >
>> org.apache.servicemix.camel.JbiEndpoint$JbiProducer.process(JbiEndpoint.java:94)
>> >
>> >    at
>> > org.apache.camel.processor.SendProcessor.process(SendProcessor.java:69)
>> >
>> >    at
>> >
>> org.apache.camel.processor.DelegateProcessor.processNext(DelegateProcessor.java:50)
>> >
>> >    at
>> >
>> org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:50)
>> >
>> >    at
>> >
>> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:80)
>> >
>> >    at
>> >
>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:189)
>> >
>> >    at
>> >
>> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133)
>> >
>> >    at
>> >
>> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
>> >
>> >    at
>> >
>> org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
>> >
>> >    at
>> >
>> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
>> >
>> >    at
>> >
>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
>> >
>> >    at
>> >
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>> >
>> >    at
>> >
>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>> >
>> >    at
>> >
>> org.apache.servicemix.camel.CamelProviderEndpoint.handleActiveProviderExchange(CamelProviderEndpoint.java:115)
>> >
>> >    at
>> >
>> org.apache.servicemix.camel.CamelProviderEndpoint.process(CamelProviderEndpoint.java:73)
>> >
>> >    at
>> >
>> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:627)
>> >
>> >    at
>> >
>> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:581)
>> >
>> >    at
>> >
>> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchangeInTx(AsyncBaseLifeCycle.java:478)
>> >
>> >    at
>> >
>> org.apache.servicemix.common.AsyncBaseLifeCycle$2.run(AsyncBaseLifeCycle.java:347)
>> >
>> >    at
>> >
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
>> >
>> >    at
>> >
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
>> >
>> >    at java.lang.Thread.run(Thread.java:595)
>> >
>> >
>> >
>> > On Mon, Jun 8, 2009 at 9:52 PM, Guillaume Nodet <[hidden email]>
>> wrote:
>> >
>> >> The NMR endpoints are now registered with either an INTERNAL_ENDPOINT
>> >> property or an EXTERNAL_ENDPOINT property set to true.
>> >> So this means we could add this property the props variable in order
>> >> to select the right endpoint.
>> >> The next question is: do we know if the target endpoint is an internal
>> >> endpoint or an external endpoint ?
>> >> A new test case inside jbi/itests would be nice for that.
>> >>
>> >> Anyway, I'm not so sure it will actually affect the routing.
>> >> In this bit of code, the goal is to find the channel corresponding to
>> >> the endpoint, but if it's not found, it should use the channel for the
>> >> component itself, which should still work.
>> >>
>> >> Could you paste the stack trace of the NPE you had ?  Maybe this one
>> >> should be fixed instead.
>> >>
>> >> On Mon, Jun 8, 2009 at 19:06, Edell Nolan<[hidden email]>
>> wrote:
>> >> > Hi,
>> >> >
>> >> > I am trying to run a demo against the latest kit but I seem to have
>> hit
>> >> an
>> >> > issue in the
>> >> >
>> >> > org.apache.servicemix.jbi.runtime.impl.DeliveryChannelImpl =>
>> >> >
>> >> > In the getChannelToUse there is a note about a TODO - I seem to have
>> a
>> >> case
>> >> > where I have an internal and external endpoint
>> >> > that have the same service name and endpoint name.
>> >> >
>> >> > the basic sequence of events of the demo is as follows
>> >> >
>> >> > I have an external service that submits a request using soap/http to
>> a
>> >> > service thats deployed in smx from there it is routed through a few
>> >> services
>> >> > based on content etc and eventually uses a CBR service based on
>> content
>> >> to
>> >> > make an external call using soap/http to an another external service.
>> >> >
>> >> > In the first attempt to make the call from the external service to
>> the
>> >> > service deployed within servicemix after debugging this code It has
>> two
>> >> > matching endpoints and as seen below none of them gets set so I end
>> up
>> >> with
>> >> > a Null pointer exception in AssemblyReferencesListener due to no
>> assembly
>> >> > but its because the channel is wrong.
>> >> >
>> >> > If I force the below to use one of the matching endpoints then I can
>> >> proceed
>> >> > with my call going into myService but when it attempts to make an
>> >> external
>> >> > call back out I end up with no match and again the channel is wrong
>> and
>> >> > falls over with a Null pointer Exception.
>> >> >
>> >> > Is there a way I can get around this ?
>> >> >
>> >> > thanks, Edell.
>> >> >
>> >> >
>> >> > protected Channel getChannelToUse(InternalExchange exchange) {
>> >> >        Channel channelToUse = channel;
>> >> >        if (exchange.getSource() == null) {
>> >> >            // We need to look up the channel corresponding to the
>> sender
>> >> > endpoint
>> >> >            try {
>> >> >                String sender = (String)
>> >> > exchange.getProperty(SENDER_ENDPOINT);
>> >> >                if (sender != null) {
>> >> >                    int idx = sender.lastIndexOf(':');
>> >> >                    String svc = sender.substring(0, idx);
>> >> >                    String ep = sender.substring(idx + 1);
>> >> >                    Map<String, Object> props =
>> >> > ServiceHelper.createMap(Endpoint.SERVICE_NAME, svc,
>> >> >
>> >> > Endpoint.ENDPOINT_NAME, ep);
>> >> >                    // TODO: we may be using the wrong channel if both
>> an
>> >> > internal endpoint and an external endpoint
>> >> >                    // have been registered with the same svc / ep
>> name
>> >> >                    List<Endpoint> eps =
>> >> > channel.getNMR().getEndpointRegistry().query(props);
>> >> >                    if (eps != null && eps.size() == 1) {
>> >> >                        channelToUse = ((InternalEndpoint)
>> >> > eps.get(0)).getChannel();
>> >> >                    }
>> >> >                }
>> >> >            } catch (Throwable t) {
>> >> >                // Ignore
>> >> >            }
>> >> >        } else {
>> >> >            channelToUse = exchange.getSource().getChannel();
>> >> >        }
>> >> >        return channelToUse;
>> >> >    }
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Cheers,
>> >> Guillaume Nodet
>> >> ------------------------
>> >> Blog: http://gnodet.blogspot.com/
>> >> ------------------------
>> >> Open Source SOA
>> >> http://fusesource.com
>> >>
>> >
>>
>
>