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]

Reply via email to