Hello all,

I've been experimenting with the WS-Notification support in servicemix 3.3.2 
and am now testing it in 4.2.0.  

This begs the question, how stable is 4.2.0?  I've stuck with 3.3.2 thus far 
because the wsn-http-biding example is not part of the examples provided in 
4.2.0 distribution.  Here is what I've found so far:

You have to patch 3.3.2 to get the wsn-http-binding to work
https://issues.apache.org/jira/browse/SM-1783
The simplest way to do this is to grab the class FragmentStreamReader.class out 
of the servicemix-utils jar file in 4.2.0 and put it in the servicemix-utils, 
or you could more prudently compile the version attached to the JIRA issue.

PullPoint(i.e. Queue)
After this was done I successfully created a pullpoint, sent notify messages to 
that pullpoint and got the messages back with a getmessages call.  

Subscription(i.e. Topic)
I also created a subscription to a topic by subscribing a simple echo server on 
localhost:4444.  It simply echos whatever is sent to it and sends back HTTP OK 
200.
I then sent a notify message to that topic (no <wsa:To> field specified in the 
header) and received the message from the echo server.

The creation of subscriptions and pullpoints works great in 3.3.2 but tearing 
them down is more difficult.  

Unsubscribing
-----------------
  When creating a subscription it returns an address like the one below in the 
response
<ns2:Address>http://servicemix.org/wsnotification/Subscription/ID-192-168-0-164-12cf0719623-0-1</ns2:Address>
This is an internal endpoint address and cannot be accessed externally.  It has 
been previously mentioned on the mailing list that to perform an unsubscribe 
you must send  <wsnt:Unsubscribe/> to that internal endpoint.  I modified the 
wsdl-first example to use the personId to perform the unsubscribe operation.

Here sample code to perform the unsubscribe operation inside a POJO.
----------------------------------------------------------------------------
      ServiceMixClient client = new ServiceMixClientFacade(this.context);
      Destination destination = 
client.createDestination("service:http://servicemix.org/wsnotification/Subscription";);

      InOut exchange = destination.createInOutExchange();

      NormalizedMessage message = exchange.getInMessage();
      message.setProperty("endpoint", subId);
      message.setContent(new StreamSource(new StringReader( "<wsnt:Unsubscribe 
xmlns:wsnt=\"http://docs.oasis-open.org/wsn/b-2\"/>") ));

      client.sendSync(exchange);
----------------------------------------------------------------------------

DestroyPullPoint
----------------
To Destroy a pullpoint the following xml must be sent.

<wsnt:DestroyPullPoint 
  xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2";
  xmlns:sm="http://servicemix.apache.org/wsn2005/1.0";>
<sm:address> 
    http://www.consumer.org/service/endpoint
  </sm:address>
</wsnt:DestroyPullPoint>

This is where I get confused.  The two wsn-http bindings (CreatePullPoint and 
NotificationBroker) display the following operations when accessed with SOAPUI 
- CreatePullPoint
- GetCurrentMessage
- Notify
- RegisterPublisher
- Subscribe

Athough neither binding states in it's wsdl that it accepts DestroyPullPoint 
both endpoints (http://localhost:8192/CreatePullPoint and 
http://localhost:8192/NotificationBroker) accept a DestroyPullPoint request.  
How does this work?

In 4.2.0 DestroyPullPoint does not work  and generates the following in the log:

-------- Begin Error --------

293 | Error processing exchange [
  id:        c7c88687-507a-4e45-b39e-580ad0d7c0ab
  mep:       InOut
  status:    Done
  role:      Consumer
  target:    
PropertyMatchingReference[{INTERFACE_NAME={http://docs.oasis-open.org/wsn/bw-2}PullPoint}]
  operation: {http://docs.oasis-open.org/wsn/bw-2}DestroyPullPointRequest
  properties: [
      javax.jbi.servicedesc.ServiceEndpoint = 
org.apache.servicemix.jbi.runtime.impl.endpointi...@1f86f75
      org.apache.servicemix.senderEndpoint = 
{http://servicemix.org/wsnotification}NotificationBroker:http-bin
ding
      javax.jbi.messaging.MessageExchange = 
org.apache.servicemix.jbi.runtime.impl.inouti...@4bbcb1
      javax.jbi.messaging.sendSync = <null>
      javax.jbi.InterfaceName = {http://docs.oasis-open.org/wsn/bw-2}PullPoint
      javax.jbi.ServiceEndpoint = 
org.apache.servicemix.jbi.runtime.impl.serviceendpointi...@512035
      javax.jbi.transaction.jta = <null>
      org.apache.servicemix.correlationId = c7c88687-507a-4e45-b39e-580ad0d7c0ab
      javax.jbi.ServiceName = <null>
  ]
  In: [
    content: org.apache.servicemix.jbi.jaxp.staxsou...@1a60e09
    properties: [
      org.apache.servicemix.soap.headers = 
{{http://www.w3.org/2005/08/addressing}Action=[#document-fragment:
null]}
    ]
  ]
  Out: [
    content: <?xml version="1.0" encoding="UTF-8" 
standalone="no"?><ns5:DestroyPullPointResponse xmlns:ns5="ht
tp://docs.oasis-open.org/wsn/b-2" 
xmlns:ns2="http://www.w3.org/2005/08/addressing"; xmlns:ns3="http://docs.oasi
s-open.org/wsrf/bf-2" xmlns:ns4="http://docs.oasis-open.org/wsrf/rp-2"; 
xmlns:ns6="http://docs.oasis-open.org/w
sn/t-1"/>
  ]
]

org.apache.servicemix.nmr.core.ChannelClosedException
        at 
org.apache.servicemix.nmr.core.ChannelImpl.deliver(ChannelImpl.java:192)

---- End Error ------------

Create/Create/Destroy -- Bug?
I found what I believe may be a bug when I was playing with CreatePullPoint and 
DestroyPullPoint.  In 3.3.2 you can create the pullpoint and then destroy the 
pullpoint as much as you like.  But if you accidently call the create twice in 
a row using the same defined address the server appears to get in a bad state. 
The second CreatePullPoint will cause a soap fault but then the 
DestroyPullPoint will receive an HTTP 500 error response with a stack trace.

   <h2>HTTP ERROR 500</h2>
      <p>
         Problem accessing /CreatePullPoint/. Reason:
         <pre>INTERNAL_SERVER_ERROR</pre>
      </p>
      <h3>Caused by:</h3>
      <pre>java.lang.NullPointerException
        at 
org.apache.servicemix.wsn.component.WSNEndpoint.process(WSNEndpoint.java:141)
        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:885)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)</pre>
      <hr/>
      <i>
         <small>Powered by Jetty://</small>
      </i>




I've tested pullpoints in 4.2.0 but subscriptions do not appear to work.

To setup the subscription I send a subscribe request and then test it with a 
notify request.

-- Subscription request --
<env:Envelope
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/";
    xmlns:wsa="http://www.w3.org/2005/08/addressing";>
<env:Header>
<wsa:ReplyTo>
      <wsa:Address>http://localhost:4444</wsa:Address>
 </wsa:ReplyTo>
 <wsa:From>
      <wsa:Address>http://localhost:4444</wsa:Address>
 </wsa:From>
</env:Header>
  <env:Body>
    <wsnt:Subscribe
      xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2";
      xmlns:ncex="http://www.consumer.org";
      xmlns:npex="http://www.producer.org";>
      <wsnt:ConsumerReference>
        <wsa:Address>
          http://localhost:4444
        </wsa:Address>
      </wsnt:ConsumerReference>
      <wsnt:Filter>
        <wsnt:TopicExpression
            Dialect="http://docs.oasis-open.org/wsn/t-1/TopicExpression/Simple";>
          BrewProcess
        </wsnt:TopicExpression>
      </wsnt:Filter>
    </wsnt:Subscribe>
  </env:Body>
</env:Envelope>
-- End Subscription request --

-- Notification -
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/";
 xmlns:wsa="http://www.w3.org/2005/08/addressing";>
<env:Header>

</env:Header>
<env:Body>
<wsnt:Notify xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2";>
<wsnt:NotificationMessage>
<wsnt:Topic Dialect="http://docs.oasis-open.org/wsn/t-1/TopicExpression/Simple";>
BrewProcess
</wsnt:Topic>
<wsnt:Message>
<alarm:Alarm xmlns:alarm="http://alarms.some-host";>
<Name>Kettle Overfill</Name>
<Desc>Kettle Overfill Alarm</Desc>
<Date>2007-09-22-12:00:30:100</Date>
<Severity>3</Severity>
<Value>110.2</Value>
<Ack>false</Ack>
</alarm:Alarm>
</wsnt:Message>
</wsnt:NotificationMessage>
</wsnt:Notify>
</env:Body>
</env:Envelope>

-- End Notification --

Service mix throws the following error:

15:44:34,369 | WARN  | eMQ Session Task | NMR                              | 
.servicemix.nmr.core.ChannelImpl
 293 | Error processing exchange [
  id:        4bb50aca-6177-4062-9d2b-c1b403341dae
  mep:       InOnly
  status:    Active
  role:      Consumer
  target:    PropertyMatchingReference[{ENDPOINT_NAME=http://localhost:4444, 
SERVICE_NAME={urn:servicemix:http
}HttpComponent}]
  properties: [
      org.apache.servicemix.senderEndpoint = 
{http://servicemix.org/wsnotification}Subscription:ID-192-168-0-1
64-12cf0b213b4-2-0
      javax.jbi.messaging.MessageExchange = 
org.apache.servicemix.jbi.runtime.impl.inonlyi...@ff9738
      javax.jbi.messaging.sendSync = <null>
      javax.jbi.transaction.jta = <null>
      javax.jbi.ServiceEndpoint = 
org.apache.servicemix.common.resolvedendpo...@2103ff
      org.apache.servicemix.correlationId = 4bb50aca-6177-4062-9d2b-c1b403341dae
  ]
  In: [
    content: <?xml version="1.0" encoding="UTF-8"?><ns2:Notify 
xmlns:ns2="http://docs.oasis-open.org/wsn/b-2";
xmlns="http://www.w3.org/2005/08/addressing"; 
xmlns:ns3="http://docs.oasis-open.org/wsrf/bf-2"; xmlns:ns4="http:
//docs.oasis-open.org/wsrf/rp-2" 
xmlns:ns5="http://docs.oasis-open.org/wsn/t-1";><ns2:NotificationMessage><ns2:
Topic Dialect="http://docs.oasis-open.org/wsn/t-1/TopicExpression/Simple";>
BrewProcess
</ns2:Topic><ns2:Message><alarm:Alarm xmlns:alarm="http://alarms.some-host"; 
xmlns:env="http://schemas.xmlsoap.
org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing"; 
xmlns:wsnt="http://docs.oasis-open.org/ws
n/b-2"><Name xmlns="" xmlns:ns10="http://www.w3.org/2005/08/addressing";>Kettle 
Overfill</Name><Desc xmlns="" x
mlns:ns10="http://www.w3.org/2005/08/addressing";>Kettle Overfill 
Alarm</Desc><Date xmlns="" xmlns:ns10="http:/
/www.w3.org/2005/08/addressing">2007-09-22-12:00:30:100</Date><Severity 
xmlns="" xmlns:ns10="http://www.w3.org
/2005/08/addressing">3</Severity><Value xmlns="" 
xmlns:ns10="http://www.w3.org/2005/08/addressing";>110.2</Valu
e><Ack xmlns="" xmlns:ns10="http://www.w3.org/2005/08/addressing";>false</Ack>
</alarm:Alarm></ns2:Message></ns2:NotificationMessage></ns2:Notify>
  ]
]

org.apache.servicemix.nmr.api.ServiceMixException: Could not dispatch exchange. 
No matching endpoints.
        at 
org.apache.servicemix.nmr.core.FlowRegistryImpl.dispatch(FlowRegistryImpl.java:110)
        at 
org.apache.servicemix.nmr.core.ChannelImpl.dispatch(ChannelImpl.java:286)


Is version 4.2.0 interpreting http://localhost:4444 as an internal endpoint 
address?

If you've made it this far, congratulations.  Here is a quick summary of the 
questions:

How stable is 4.2.0 with regard to WS-Notifications?  
How is the destroyPullPoint operation working successfully in 3.3.2 even though 
the operation is not defined in the WSDL?
Is version 4.2.0 interpreting http://localhost:4444 as an internal endpoint 
address?

Thanks in advance

Matthieu Cormier
Cell: (902) 229-1677
concertia Technologies Inc.
1869 Upper Water Street
Halifax NS B3J 1S9 
www.concertia.com

Reply via email to