You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-user@ws.apache.org by Ch...@swisscom.com on 2007/07/25 17:14:54 UTC

PullPoint subscriptions - PublishAllMessagesFilter and statics in AbstractIsolationLayer

Hi All,

First off I find Muse to be incredibly well designed software and mostly
bug free, got to say I'm extremely impressed (especially when coupled
with TPTP).

However both I; and Marjan Sterjev; note that you need the first
subscription to get a reference from the producer.  This then receives
all of the messages sent on that wsresource.  I agree that this is the
incorrect approach according to the specs (and expectations).

Whilst this isn't meant as a patch to the muse code, the following
implementations will only collect the messages subscribed to (at least
in my tests).  If they help Marjan and others that's cool, sample code
use below.

First question: in the PullPoint accept method I just return true, based
on the assumption that the router will only send Notify to this resource
instance if it was the target of a subscription (from the WSA header to
and resource param).  Is this assumption correct?

Second question: was there a design decision behind the use of statics
in AbstractIsolationLayer?  As is the default won't retrieve a new
environment if it is shutdown then restarted again (in my case this
requires a new environment to be created).  I have simply implemented
IsolationLayer with copy+paste and got rid of the statics, will this
likely cause any issues (hence the question of design decision, maybe
there is something I'm not seeing)?

TIA and cheers,
Chris

PS (The reason why these do not derive is because the simplepullpoint
shutdown code won't work when there isn't a subscription)
PPS (many thanks for this great software)

Code used as (where adapterStatus implements pullpoints and
immediateresourcetermination):

		EndpointReference source = new EndpointReference(new
URI("source://tests"));
		EndpointReference target = new EndpointReference(new
URI("target://some/uri"));

		adapterStatusProxy resource = new adapterStatusProxy(
target, source, new SimpleSoapClient());
		
		Element el = resource.createPullPoint();
		EndpointReference pullpoint = new EndpointReference(el);
		
		// register a consumer.
		SubscriptionClient client =
resource.subscribe(pullpoint, new
TopicFilter(LogLevelCapability.LEVELCHANGED_TOPIC_NAME), null);
		
		// should only get once per each change (seperate
notify)
		resource.updatelogLevel("info");
		resource.updatelogLevel("debug");
		resource.updatelogLevel("info"); 		
		
		// run in another thread so we'll have to wait a while..
		try {
			Thread.sleep(1000);
//			System.in.read();
		} catch (Exception e) {
		}
		
		// get the messages?
		Element max =
XmlUtils.createElement(el.getOwnerDocument(), new
QName("http://docs.oasis-open.org/wsn/b-2", "MaximumNumber", "pfx0"),
new Integer(10));

		adapterStatusProxy pullit = new adapterStatusProxy(
pullpoint, source, new EsbSoapClient(new ProxyHelper(adapter)
		, DispatchContext.ESB_TESTS));

		Element[] res = pullit.getMessages(max);
		client.destroy();
		
		pullit.destroy();
		assertEquals(3, res.length); // property change
notification as well would be 6


RE: PullPoint subscriptions - PublishAllMessagesFilter and statics in AbstractIsolationLayer

Posted by Ch...@swisscom.com.
sorry, seems attachments don't work.  added inline....

------ PullPointCreation

package muse.wsn.impl;

import org.apache.muse.core.ResourceManager;
import org.apache.muse.ws.addressing.EndpointReference;
import org.apache.muse.ws.addressing.soap.SoapFault;
import org.apache.muse.ws.notification.PullPoint;
import
org.apache.muse.ws.notification.faults.UnableToCreatePullPointFault;
import org.apache.muse.ws.resource.WsResource;
import org.apache.muse.ws.resource.impl.AbstractWsResourceCapability;

/**
 * factory that creates a new resource for doing pullpoints.
 * 
 * @author TGDTWCH1
 *
 */
public class PullPointCreation extends AbstractWsResourceCapability
implements
		org.apache.muse.ws.notification.PullPointCreation {

    //
    // context path of the pullpoint resource type
    //
    private String _pullPointPath = null;

    public EndpointReference createPullPoint() 
        throws UnableToCreatePullPointFault
    {
        ResourceManager manager = getResource().getResourceManager();
        
        //
        // create the resource to represent the pullpoint
        //
        String endpoint = getPullPointContextPath();
        WsResource pullPoint = null;
        
        try
        {
            pullPoint = (WsResource)manager.createResource(endpoint);
        }
        
        catch (SoapFault error)
        {
            throw new UnableToCreatePullPointFault(error);
        }
        
        EndpointReference epr = pullPoint.getEndpointReference();
        
        //
        // initialize pullpoint to complete creation process
        //
        try
        {
            pullPoint.initialize(); // adds itself to the consumer
            manager.addResource(epr, pullPoint);
        }
        
        catch (SoapFault error)
        {
            throw new UnableToCreatePullPointFault(error);
        }
        
        return epr;        
    }
    
    /**
     * 
     * @return pullpoint context path
     */
    protected String getPullPointContextPath()
    {
        return _pullPointPath;
    }
    
    public void initialize() throws SoapFault
    {
        super.initialize();
        
        //
        // find pullpoint resource type so we can create instances of it

        // in createPullPoint()
        //
        ResourceManager manager = getResource().getResourceManager();
        _pullPointPath =
manager.getResourceContextPath(PullPoint.class);
        if (_pullPointPath == null)
            throw new RuntimeException("No PullPoint endpoint
deployed");
    }

}


------ PullPoint

package muse.wsn.impl;

import org.apache.muse.ws.addressing.soap.SoapFault;
import org.apache.muse.ws.notification.Filter;
import org.apache.muse.ws.notification.NotificationConsumer;
import org.apache.muse.ws.notification.NotificationMessage;
import org.apache.muse.ws.notification.NotificationMessageListener;
import org.apache.muse.ws.notification.PullPointDataStore;
import org.apache.muse.ws.notification.WsnConstants;
import org.apache.muse.ws.notification.faults.UnableToGetMessagesFault;
import org.apache.muse.ws.notification.impl.SimplePullPointDataStore;
import org.apache.muse.ws.resource.WsResource;
import org.apache.muse.ws.resource.impl.AbstractWsResourceCapability;

/**
 * This version doesn't do its own subscribe all !!!!
 * 
 * @author TGDTWCH1
 *
 */
public class PullPoint extends AbstractWsResourceCapability implements
org.apache.muse.ws.notification.PullPoint, NotificationMessageListener {
    //
    // the place where we keep messages until a client asks for them
    //
    private PullPointDataStore _dataStore = null;
    
    /**
     * 
     * Users can override this method to provide an alternate
implementation 
     * of the PullPointDataStore API.
     *
     * @return An instance of SimplePullPointDataStore
     *
     */
    protected PullPointDataStore createDataStore()
    {
        return new SimplePullPointDataStore();
    }

    public PullPointDataStore getDataStore()
    {
        return _dataStore;
    }
    
    /**
     * 
     * @return An instance of PublishAllMessagesFilter. This allows the
pullpoint 
     *         to add all messages to its data store.
     * 
     */
    public Filter getFilter()
    {
        return null;
    }

    public NotificationMessage[] getMessages(int maxNumber) 
        throws UnableToGetMessagesFault
    {
        return getDataStore().getMessages(maxNumber);
    }
    
    public void initialize() 
        throws SoapFault
    {
        super.initialize();
        
        _dataStore = createDataStore();
        _dataStore.initialize();
        
        //
        // register for messages so we can add them to the data store
        //
        NotificationConsumer wsn =
(NotificationConsumer)getResource().getCapability(WsnConstants.CONSUMER_
URI);
        wsn.addMessageListener(this);
    }
    
    public void process(NotificationMessage message) 
        throws SoapFault
    {
        getDataStore().addMessage(message);
    }

    public void shutdown() 
        throws SoapFault
    {
        getDataStore().shutdown();
        super.shutdown();
    }

	public boolean accepts(NotificationMessage message)
	{
		// the fact its routed to here means the message headers
MUST have the correct resource
		return true;
	}

	// the subscription methods aren't used here, subscriptions
belong to the client of a pullpoint
	public WsResource getSubscription() {
		return null;
	}

	public void setSubscription(WsResource arg0) {
		
	}
}

-----Original Message-----
From: Twiner Chris, IT-TBU-DL2-EAI-EDE 
Sent: Wednesday, July 25, 2007 5:15 PM
To: muse-user@ws.apache.org
Subject: PullPoint subscriptions - PublishAllMessagesFilter and statics
in AbstractIsolationLayer

---------------------------------------------------------------------
To unsubscribe, e-mail: muse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-user-help@ws.apache.org


RE: PullPoint subscriptions - PublishAllMessagesFilter and statics in AbstractIsolationLayer

Posted by Ch...@swisscom.com.
After fighting with Axis 1.4 for almost a month to get a stable level
2.0 DOM and saaj (that works with WSS4J etc) its very refreshing to not
have to fight software to extend it.  The worst I've had to do with Muse
is copy and paste one class to get rid of the statics.

The explanation makes sense.  In our case I'm integrating muse as a
management layer into our inhouse ESB.  We need to be able to
restart/reload the services at runtime without loss of service, the
SoapClient/Environment in particular is tied to an instance of the ESB
(allowing sending to MQ etc instead of just http).  The statics then
showed up as exceptions when trying to use the first initial
environment.

Given the background I think its fine to just use non-statics.

Regarding:

> First question: in the PullPoint accept method I just return true, 
> based on the assumption that the router will only send Notify to this 
> resource instance if it was the target of a subscription (from the WSA

> header to and resource param).  Is this assumption correct?

Is this ok to assume?  The pullpoint is a new resource so I think it
must be but I wanted to check.  If so I'd raise a jira to have the
default PullPoint implementation changed to this model (or at least
provide the alternatives :-).

cheers,
Chris

-----Original Message-----
From: Daniel Jemiolo [mailto:danjemiolo@us.ibm.com] 
Sent: Friday, August 10, 2007 6:53 PM
To: muse-user@ws.apache.org
Subject: Re: PullPoint subscriptions - PublishAllMessagesFilter and
statics in AbstractIsolationLayer



"Bug free" is a stretch, but thanks anyway.  ;)

As I recall, AbstractIsolationLayer started out as a normal class and
was changed to be static because of problems we had setting the class
loading scope on various SOAP engines. Long ago, when we just ran on
Axis 1.x, we used its service scope (request|application|...) to make it
so the service stayed loaded for as long as the server was up; for
whatever reason, expanding to Axis2, the mini SOAP engine, WebSphere,
etc., led to some inconsistency and making things static was the only
way to ensure we got the proper behavior. Otherwise, the Muse engine
would reload for each request, which is obviously a bad thing.

It's odd that you're seeing the static class behavior even after
shutting down the app and restarting - I thought that this would cause
the app server to unload the app's local classloader. Are all of your
Muse JARs in the web app's /WEB-INF/lib, or have you added them to one
of the server's common library directories?

Dan



---------------------------------------------------------------------
To unsubscribe, e-mail: muse-user-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-user-help@ws.apache.org


Re: PullPoint subscriptions - PublishAllMessagesFilter and statics in AbstractIsolationLayer

Posted by Daniel Jemiolo <da...@us.ibm.com>.

"Bug free" is a stretch, but thanks anyway.  ;)

As I recall, AbstractIsolationLayer started out as a normal class and was
changed to be static because of problems we had setting the class loading
scope on various SOAP engines. Long ago, when we just ran on Axis 1.x, we
used its service scope (request|application|...) to make it so the service
stayed loaded for as long as the server was up; for whatever reason,
expanding to Axis2, the mini SOAP engine, WebSphere, etc., led to some
inconsistency and making things static was the only way to ensure we got
the proper behavior. Otherwise, the Muse engine would reload for each
request, which is obviously a bad thing.

It's odd that you're seeing the static class behavior even after shutting
down the app and restarting - I thought that this would cause the app
server to unload the app's local classloader. Are all of your Muse JARs in
the web app's /WEB-INF/lib, or have you added them to one of the server's
common library directories?

Dan



<Ch...@swisscom.com> wrote on 07/25/2007 11:14:54 AM:

> Hi All,
>
> First off I find Muse to be incredibly well designed software and mostly
> bug free, got to say I'm extremely impressed (especially when coupled
> with TPTP).
>
> However both I; and Marjan Sterjev; note that you need the first
> subscription to get a reference from the producer.  This then receives
> all of the messages sent on that wsresource.  I agree that this is the
> incorrect approach according to the specs (and expectations).
>
> Whilst this isn't meant as a patch to the muse code, the following
> implementations will only collect the messages subscribed to (at least
> in my tests).  If they help Marjan and others that's cool, sample code
> use below.
>
> First question: in the PullPoint accept method I just return true, based
> on the assumption that the router will only send Notify to this resource
> instance if it was the target of a subscription (from the WSA header to
> and resource param).  Is this assumption correct?
>
> Second question: was there a design decision behind the use of statics
> in AbstractIsolationLayer?  As is the default won't retrieve a new
> environment if it is shutdown then restarted again (in my case this
> requires a new environment to be created).  I have simply implemented
> IsolationLayer with copy+paste and got rid of the statics, will this
> likely cause any issues (hence the question of design decision, maybe
> there is something I'm not seeing)?
>
> TIA and cheers,
> Chris
>
> PS (The reason why these do not derive is because the simplepullpoint
> shutdown code won't work when there isn't a subscription)
> PPS (many thanks for this great software)
>
> Code used as (where adapterStatus implements pullpoints and
> immediateresourcetermination):
>
>       EndpointReference source = new EndpointReference(new
> URI("source://tests"));
>       EndpointReference target = new EndpointReference(new
> URI("target://some/uri"));
>
>       adapterStatusProxy resource = new adapterStatusProxy(
> target, source, new SimpleSoapClient());
>
>       Element el = resource.createPullPoint();
>       EndpointReference pullpoint = new EndpointReference(el);
>
>       // register a consumer.
>       SubscriptionClient client =
> resource.subscribe(pullpoint, new
> TopicFilter(LogLevelCapability.LEVELCHANGED_TOPIC_NAME), null);
>
>       // should only get once per each change (seperate
> notify)
>       resource.updatelogLevel("info");
>       resource.updatelogLevel("debug");
>       resource.updatelogLevel("info");
>
>       // run in another thread so we'll have to wait a while..
>       try {
>          Thread.sleep(1000);
> //         System.in.read();
>       } catch (Exception e) {
>       }
>
>       // get the messages?
>       Element max =
> XmlUtils.createElement(el.getOwnerDocument(), new
> QName("http://docs.oasis-open.org/wsn/b-2", "MaximumNumber", "pfx0"),
> new Integer(10));
>
>       adapterStatusProxy pullit = new adapterStatusProxy(
> pullpoint, source, new EsbSoapClient(new ProxyHelper(adapter)
>       , DispatchContext.ESB_TESTS));
>
>       Element[] res = pullit.getMessages(max);
>       client.destroy();
>
>       pullit.destroy();
>       assertEquals(3, res.length); // property change
> notification as well would be 6
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: muse-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: muse-user-help@ws.apache.org