Thanks for the reply.
However the use of the 'old' topic is intentional: what I'd like to do is
to throw events in the MyTopic topic from within the setMyParameter method.
Therefore I call:
public void setMyParameter(int param0) {
_MyParameter = param0;
QName messageName = new QName(NAMESPACE_URI, "MyParameterUpdate", PREFIX);
Element payload = XmlUtils.createElement(messageName, "MyParameter has been
updated.");
wsn.publish(_TOPIC_NAME, payload);
}
I really can't understand why if I call message.getTopic() from a consumer
application, I get
{http://ws.example.com/muse/test/notification}MyParameter<http://ws.example.com/muse/test/notification%7DMyParameter>(I
expected MyTopic or eventually MyParameterUpdate,
but not MyParameter that is the name of the property).
The thing is shown here: (from:
http://ws.apache.org/muse/docs/2.0.0/manual/how-to/publish-any-notification.html
)
// you can add topics programmatically or via RMD document
//
QName topicName = new QName("http://example.com/server-product",
"ServerUpdates");
wsn.addTopic(topicName);
//
// you can later publish messages to the topic
//
QName messageName = new QName("http://example.com/server-product",
"UpdateMessage");
String updateMessage = "Something important happened!";
Element payload = XmlUtils.createElement(messageName, updateMessage);
wsn.publish(topicName, payload);
The code publishes a message ('UpdateMessage) with description ("Something
important happened") to a previously defined Topic. That is exactly what I'm
trying to do. And I expect that a consumer application catches and processes
these events if I write into the accept() method:
QName topicName = new QName("http://example.com/server-product",
"ServerUpdates");
QName tn = message.getTopic();
return topicName.equals(tn);
This method should return TRUE if events generated with the code above, but
in my case does not.
Am I understanding correctly the use of topics and subscriptions?
Thanks in advance,
Marco
2007/4/16, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
I believe that you setup for your NotificationProducer in your "Runtime"
event is the part causing you the problem.
The code below should help, as far as I see it your still publishing
with your old topic [wsn.publish(_TOPIC_NAME, payload);]
QName messageName = new QName(NAMESPACE_URI, "MyParameterUpdate",
PREFIX);
Wsn.addTopic(messageName);
Element payload = XmlUtils.createElement(messageName, "MyParameter has
been
updated.");
try {
wsn.publish (messageName, payload);
} catch (Throwable error) {
error.printStackTrace();
}
/Lenni
-----Original Message-----
From: Marco Parmiani [mailto:[EMAIL PROTECTED]
Sent: 16 April 2007 15:50
To: [email protected]
Subject: Regarding Muse Topics and subscriptions
Hello, I'm quite new to Muse and I'd like to better understand the
Topics
mechanism.
This is what I've done:
I took the wsdl included in wsn-producer example (added a new parameter,
called MyParameter), followed the tutorial on the site and generated
correctly the classes (and the war file).
For the Topic name I specified:
// NAMESPACE_URI = "http://ws.example.com/muse/test/notification",
PREFIX
="tns"
private static final QName _TOPIC_NAME = new QName(NAMESPACE_URI,
"MyTopic",
PREFIX);
and into initializeCompleted() I added:
wsn =
(NotificationProducer)res.getCapability(WsnConstants.PRODUCER_URI);
wsn.addTopic(_TOPIC_NAME);
In setMyParameter(int param0) method I added the code for 'throwing' new
events:
QName messageName = new QName(NAMESPACE_URI, "MyParameterUpdate",
PREFIX);
Element payload = XmlUtils.createElement(messageName, "MyParameter has
been
updated.");
try {
wsn.publish(_TOPIC_NAME, payload);
} catch (Throwable error) {
error.printStackTrace();
}
Now, from what I understand that code will throw new events on the Topic
named MyTopic. These events are messages named MyParameterUpdate and
they
include my description "MyParameter has been updated".
The problem is that when I use the wsn-consumer (a little bit
customized) I
do not get the result I expect:
ConsumerCapabilityImpl.java:
// ...imports and class def
private QName topicname = null;
String PREFIX = "tns";
String NAMESPACE_URI = "http://ws.example.com/muse/test/notification";
public void initializeCompleted()
throws SoapFault
{
super.initializeCompleted();
topicname = new QName(NAMESPACE_URI, "MyTopic", PREFIX);
NotificationConsumer wsn =
(NotificationConsumer)getResource().getCapability(WsnConstants.CONSUMER_
URI);
wsn.addMessageListener(this);
}
public boolean accepts(NotificationMessage message)
{
// should accept only messages whose topic is MyTopic
QName tn = message.getTopic();
return topicname.equals(tn);
}
public void process(NotificationMessage message)
{
getLog().info("Received message:\n\n" + message);
}
If I print the message.getTopic() I get:
{http://ws.example.com/muse/test/notification}MyParameter and not
MyTopic
(and consequently the process() method does not get called)...In
addition,
if I look the soap messages stores in the logfile of the consumer, I do
not
see anywhere neither "MyParameterUpdate" (the name of the message I set
up
in setMyParameter) nor "MyParameter has been updated." Could anyone
explain
to me this behaviour?
What's the difference between the use of accept() method into the
consumer
application and the use of producer.subscribe(consumer, new
TopicFilter(qname),null) in the external class that subscribes the
consumer
to the producer?
Thanks and sorry for the long post,
Marco
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]