Thanks for the example, Guillaume,
I would be happy to add test cases and example code when I am more
familiar with ServiceMix.
Stefan
Guillaume Nodet wrote:
Are you talking about the new servicemix-wsn2005 component ?
If no, you should take a look at this one, which is the new
and more complete version of the ws-notification component.
This component implements the Web Services Brokered Notification
1.3 (from 7 July 2005) [1].
We do not use the NotificationProducer interface directly. This
interface is defined in WS-BaseNotification for
services that can accept subscriptions. The WS-BrokeredNotification
goes one step further and defines a NotificationBroker which is
responsible for managing both producers and subscribers.
As a producer, you can register yourselef to the NotificationBroker
by sending a message. When you want to create a notification,
you send a message to the NotificationBroker.
As a consumer, you can subscribe to a given topic by sending a
message to the NotificationBroker. When a notification is received by
the NotificationBroker, it will send it to all subscribers, applying
xpath filters if necessary. You can also create a pullpoint
and poll yourself the pullpoint for new messages.
A simple client API (to use from within the jbi bus) can be used to
perform all these tasks.
Subscribing:
JBIContainer jbi = ...
QName service = new QName(...)
String endpoint = "...";
NotificationBroker wsnBroker = new NotificationBroker(jbi);
EndpointReferenceType epr = *new* EndpointReferenceType();
epr.setAddress(*new* AttributedURIType());
epr.getAddress().setValue(service.getNamespaceURI() + *"/"* +
service.getLocalPart() + *"/"* + endpoint);
wsnBroker.subscribe(epr, "myTopic", "/@type = 'foo'");
Publishing:
JBIContainer jbi = ...
Element notification = ...; // w3c dom element
NotificationBroker wsnBroker = new NotificationBroker(jbi);
wsnBroker.notify("myTopic", notification);
Take a look at the test case [2] for more informations.
Accessing the NotificationBroker on http+soap is just a matter of
adding a binding component, which targets the NotificationBroker
endpoint.
service: new QName("http://servicemix.org/wsnotification",
"NotificationBroker")
To use it, just drop the component installer in the "install"
directory of ServiceMix
distribution.
I do agree that we miss a real example, but we welcome all
contributions :)
Cheers,
Guillaume Nodet
[1] http://docs.oasis-open.org/wsn/
[2]
https://svn.apache.org/viewcvs.cgi/incubator/servicemix/trunk/servicemix-wsn2005/src/test/java/org/apache/servicemix/wsn/component/WSNComponentTest.java?rev=371950&view=markup
Stefan Klinger wrote:
Hello,
I am trying to understand the WS Notification implementation within
ServiceMix. As far as I can tell the NotificationBroker is
implemented as an endpoint and not as a component. Is there a reason
for that? There also seems to be a WSNComponent and I can't tell what
it is used for.
Maybe a simple example would be helpful showing a notification
component (created using the ClassPathXmlApplicationContext) that
notifies other components. It would be great if I could access that
component via http+soap.
BTW, Am I right in assuming that a NotificationBroker is equivalent
to a NotificationProducer in the WS Notification specification?
Thanks,
Stefan