Giter Club home page Giter Club logo

stilts's Introduction

Stilts - STOMP Integration Layer

http://stilts.projectodd.org/

Building

To build, you need Maven 3 and the appropriate entries in your ~/.m2/settings.xml to use the JBoss maven artifact repositories.

Alternatively, you may use the included support/settings.xml via

    mvn -s ./support/settings.xml install

JBossAS Integration

Make sure you have a JBossAS version that supports the jboss netty bundle. Check if this pull request already made it upstream. If not, use this branch.

Add the the netty bundle to the list of auto installed bundles.

    <modules>
        ...
        <module identifier="org.jboss.netty" startlevel="2"/>
        ...
    </modules>

Set the JBOSS_HOME environment variable and copy the stilts-stomplet-server-bundle.jar to the deployments folder.

    $ export JBOSS_HOME=~/git/.../build/target/jboss-as-7.1.0.Alpha1-SNAPSHOT
	$ mvn install
	$ cp stomplet-server-bundle/target/stilts-stomplet-server-bundle.jar $JBOSS_HOME/standalone/deployments/

Startup the server. You should see

	20:02:42,327 INFO  [org.jboss.osgi.framework.internal.BundleManager] (MSC service thread 1-3) Install bundle: stilts-stomplet-server-bundle:0.1.16.SNAPSHOT
	20:02:42,473 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Deployed "stilts-stomplet-server-bundle.jar"
	20:02:42,527 INFO  [org.projectodd.stilts.stomplet.bundle.StompletServerActivator] (MSC service thread 1-4) start: BundleContext[stilts-stomplet-server-bundle:0.1.16.SNAPSHOT]
	20:02:42,546 INFO  [org.projectodd.stilts.stomplet.bundle.StompletServerActivator] (MSC service thread 1-4) adding transaction manager: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate@cbbaf
	20:02:42,628 INFO  [org.jboss.osgi.framework.internal.HostBundleState] (MSC service thread 1-4) Bundle started: stilts-stomplet-server-bund

Now you can run the integration tests

	$ mvn -Djbossas install
	...
	Running org.projectodd.stilts.stomplet.StompletServerTestCase
    Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.292 sec

How does it work?

The stilts-stomplet-server-bundle has a BundleActivator that

The test bundle has a BundleActivator that registers a Stomplet service

    public void start(BundleContext context) throws Exception {
        log.infof("start: %s", context);
        Dictionary props = new Hashtable();
        props.put("destinationPattern", DESTINATION_QUEUE_ONE);
        registration = context.registerService(Stomplet.class.getName(), new SimpleTestStomplet(), props);
    }

When this service gets tracked, the stilts-stomplet-server-bundle adds it to the running container

        public Object addingService(ServiceReference reference) {
            Stomplet stomplet = (Stomplet) super.addingService(reference);
            log.infof("adding: %s", stomplet);
            try {
                // Copy string properties
                Map props = new HashMap();
                for (String key : reference.getPropertyKeys()) {
                    Object value = reference.getProperty(key);
                    if (value instanceof String) {
                        props.put(key, (String) value);
                    }
                }
                String destinationPattern = props.get("destinationPattern");
                log.infof("adding: %s -> %s", destinationPattern, stomplet);
                container.addStomplet(destinationPattern, stomplet, props);
            } catch (StompException ex) {
                log.errorf(ex, "Cannot add stomplet: %s", stomplet);
            }
            return stomplet;
        }

The test client code should be obvious.

        StompClient client = new StompClient("stomp://localhost");
        client.connect();

        final CountDownLatch latch = new CountDownLatch(3);
        SubscriptionBuilder builder = client.subscribe(DESTINATION_QUEUE_ONE);
        builder.withMessageHandler(new MessageHandler() {
            public void handle(StompMessage message) {
                latch.countDown();
            }
        });
        ClientSubscription subscription = builder.start();
        
        client.send(StompMessages.createStompMessage(DESTINATION_QUEUE_ONE, "start"));

        assertTrue("No latch timeout", latch.await(10, TimeUnit.SECONDS));

        client.send(StompMessages.createStompMessage(DESTINATION_QUEUE_ONE, "stop"));

        subscription.unsubscribe();
        client.disconnect();

stilts's People

Contributors

bbrowning avatar bobmcwhirter avatar burgestrand avatar dobozysaurus avatar goldmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

stilts's Issues

Stils on Android dex issues

When using the stilts-stomp-client on Android, during compilation I get the multiple dex files error:

Error:Android Dex: [example.stomp] com.android.dex.DexException: Multiple dex files define Lorg/projectodd/stilts/stomp/Constants;

The error occurs due to the fact that the Constants.java exists in both the stom-api and stomp-client dependencies in the same package namespace.

Build of the last git fail

using the command mvn -s ./support/settings.xml install


T E S T S

Running org.projectodd.stilts.stomp.protocol.websockets.WebSocketDisconnectionNe
gotiatorTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.156 sec
Running org.projectodd.stilts.stomp.protocol.StompMessageEncoderTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.053 sec
Running org.projectodd.stilts.stomp.protocol.StompFrameEncoderTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.026 sec
Running org.projectodd.stilts.stomp.protocol.StompMessageDecoderTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.013 sec
Running org.projectodd.stilts.stomp.client.protocol.websockets.WebSocketChalleng
eTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.948 sec
Running org.projectodd.stilts.stomp.protocol.StompFrameDecoderTest
Tests run: 3, Failures: 2, Errors: 1, Skipped: 0, Time elapsed: 0.03 sec <<< FAI
LURE!

Results :

Failed tests:
testDecodeConnect(org.projectodd.stilts.stomp.protocol.StompFrameDecoderTest)
testDecodeNullTerminatedMessage(org.projectodd.stilts.stomp.protocol.StompFram
eDecoderTest)

Tests in error:
testDecodeIncomplete(org.projectodd.stilts.stomp.protocol.StompFrameDecoderTes
t)

Tests run: 14, Failures: 2, Errors: 1, Skipped: 0

Stilts.js Unable to connect to websocket server with secure true

I am having issues with subscribing to my websocket server when I turn the secure option to true. I ran an SSL validator to make sure it was set up properly and everything passed. Also to be safe, I also checked with my hosting provider so I dont believe that is the issue. And also, everything does work when secure is set to false.

The WSS is running on port 8676, and I did make sure that port is open.

I am using the Stomp Javascript library. I downloaded the latest version from this github master branch.

I keep getting this error inside the _transmit() function: can't call transmit on undefined

It seems to not be setting the _transport property inside of _buildConnector() function. I added some console.logs and it always goes to the else statement in this function.

Any ideas on a fix? Or am I just missing something?

I also want to note that the web app server and the websocket server are on 2 different machines. Not sure if that is part of the problem.

This is how I am initializing my connection:

client = new Stomp.Client('my.ip.address', 8676, true);

Here is where I am logging some of the functions:

Stomp.Client = function(host, port, secure) { console.log('host param: ' + host); console.log('port param: ' + port); console.log('secure param: ' + secure); this._host = host || Stomp.DEFAULT_HOST; this._port = port || Stomp.DEFAULT_PORT || 8675; this._secure = secure || Stomp.DEFAULT_SECURE_FLAG || false; console.log('this._host: ' + this._host); console.log('this._port: ' + this._port); console.log('this._secure: ' + this._secure); }

Output:

host param: my.ip.address port param: 8676 secure param: true this._host: my.ip.address this._port: 8676 this._secure: true

_buildConnector: function(transports, i) { console.log('INSIDE _buildConnector()'); var callback = this._connectCallback; var client = this; if ( i < transports.length ) { console.log('IF!!!'); return function() { var fallback = client._buildConnector( transports, i+1, callback ); try { console.log('_buildConnector::IF::TRY'); transports[i].connect( function() { client._transport = transports[i]; callback(); }, fallback ); } catch (err) { console.log('_buildConnector::IF::CATCH'); fallback(); } }; } else { console.log('_buildConnector::ELSE'); return client.connectionFailed.bind(this); } }

Output:

INSIDE _buildConnector() IF!!! INSIDE _buildConnector() IF!!! _buildConnector::IF::TRY INSIDE _buildConnector() _buildConnector::ELSE _buildConnector::IF::TRY

connectionFailed: function() { console.log('INSIDE connectionFailed()'); if (this._errorCallback) { console.log('connectionFailed::IF'); console.log('this._errorCallback'); console.log(this._errorCallback); console.log('arguments'); console.log(arguments); this._errorCallback.apply(this._errorCallback, arguments); } else { console.log('connectionFailed::ELSE'); console.log('unable to connect :('); Stomp.logger.log( "unable to connect" ); } }

Output:
No output..

Javascript STOMP client question

When a user's browser crashes or they navigates away from the web page where the subscriptions exist, is the client session (browser) automatically disconnected from STOMP on the server side? Or is this something that needs to be configured on the server-side?

Thanks

Using user name and password to connect server

Hi,

I've a frame like this

CONNECT
destination:/queue/ems
passcode:password
login:username

How to pass user name and password while stompClient.connect also how to validate in server side

messageReceived called twice for CONNECTED

10:20:41,019 TRACE [org.projectodd.stilts.stomp.client.protocol.StompConnectionNegotiator] (New I/O client worker #1-1) Send frame: [StompControlFrame: header=[FrameHeader: command=CONNECT; headers={host=localhost, accept-version=1.0,1.1}]]
10:20:41,043 TRACE [org.projectodd.stilts.stomp.client.protocol.AbstractClientControlFrameHandler] (New I/O client worker #1-1) received: [StompControlFrame: header=[FrameHeader: command=CONNECTED; headers={session=1363861047}]]
10:20:41,044 TRACE [org.projectodd.stilts.stomp.client.protocol.AbstractClientControlFrameHandler] (New I/O client worker #1-1) received: [StompControlFrame: header=[FrameHeader: command=CONNECTED; headers={session=1363861047}]]

http://fpaste.org/Pxky/

BasicJavascriptClientTest fails

I've just tried checking this project out of git, and mvn clean install gives me the following;

Results :

Failed tests:   should be able to receive UTF8 messages(org.projectodd.stilts.stomp.client.js.BasicJavascriptClientTest): Expected: ├ñ├ñbb, was: õõbb

(though oddly the test runs just fine from within Eclipse ...)

A single websocket message containing multiple STOMP frames

If the stilts stomp-client receives a single websocket message that contains two or more STOMP frames, then only the first of those frames is processed. This means that frames are silently lost. I've seen this against a ActiveMQ Apollo broker (simply fire two messages to a destination to which you've subscribed in quick succession; only the first will arrive) - it could no doubt occur against other brokers, too.

See also http://jmesnil.net/weblog/2012/05/15/stomp-over-websockets-with-multi-frames/

Below is an extract from the log file ...

TRACE 2014-07-14 08:59:54,513 [DebugHandler] - CLIENT_HEAD <<inbound<< [id: 0xcdde5cbd, /127.0.0.1:55694 => /127.0.0.1:8090] :: MESSAGE+BUFFER ?~�$MESSAGE
subscription:subscription-0
message-id:localhost-21
receipt:receipt-0
destination:/topic/SOME_TOPIC
content-length:17

any old content 0^@
MESSAGE
subscription:subscription-0
message-id:localhost-22
receipt:receipt-1
destination:/topic/SOME_TOPIC
content-length:17

any old content 1^@

TRACE 2014-07-14 08:59:54,514 [DebugHandler] - CLIENT_TAIL <<inbound<< [id: 0x3e06ea70, /127.0.0.1:55701 => /127.0.0.1:8090] :: [id: 0x3e06ea70, /127.0.0.1:55701 => /127.0.0.1:8090] RECEIVED: [StompControlFrame: header=[FrameHeader: command=RECEIPT; headers={receipt-id=receipt-0}]] ** class org.jboss.netty.channel.UpstreamMessageEvent
TRACE 2014-07-14 08:59:54,514 [DebugHandler] - CLIENT_TAIL <<inbound<< [id: 0x3e06ea70, /127.0.0.1:55701 => /127.0.0.1:8090] :: MESSAGE [StompControlFrame: header=[FrameHeader: command=RECEIPT; headers={receipt-id=receipt-0}]]
TRACE 2014-07-14 08:59:54,517 [DebugHandler] - CLIENT_MID <<inbound<< [id: 0xcdde5cbd, /127.0.0.1:55694 => /127.0.0.1:8090] :: [id: 0xcdde5cbd, /127.0.0.1:55694 => /127.0.0.1:8090] RECEIVED: [StompContentFrame: header=[FrameHeader: command=MESSAGE; headers={subscription=subscription-0, content-length=17, message-id=localhost-21, receipt=receipt-0, destination=/topic/SOME_TOPIC}]] ** class org.jboss.netty.channel.UpstreamMessageEvent
TRACE 2014-07-14 08:59:54,517 [DebugHandler] - CLIENT_MID <<inbound<< [id: 0xcdde5cbd, /127.0.0.1:55694 => /127.0.0.1:8090] :: MESSAGE [StompContentFrame: header=[FrameHeader: command=MESSAGE; headers={subscription=subscription-0, content-length=17, message-id=localhost-21, receipt=receipt-0, destination=/topic/SOME_TOPIC}]]
TRACE 2014-07-14 08:59:54,518 [AbstractClientControlFrameHandler] - received: [StompContentFrame: header=[FrameHeader: command=MESSAGE; headers={subscription=subscription-0, content-length=17, message-id=localhost-21, receipt=receipt-0, destination=/topic/SOME_TOPIC}]]
TRACE 2014-07-14 08:59:54,526 [DebugHandler] - CLIENT_TAIL <<inbound<< [id: 0xcdde5cbd, /127.0.0.1:55694 => /127.0.0.1:8090] :: [id: 0xcdde5cbd, /127.0.0.1:55694 => /127.0.0.1:8090] RECEIVED: [StompMessage: headers={subscription=subscription-0, content-length=17, message-id=localhost-21, receipt=receipt-0, destination=/topic/SOME_TOPIC}   content=any old content 0] ** class org.jboss.netty.channel.UpstreamMessageEvent
TRACE 2014-07-14 08:59:54,526 [DebugHandler] - CLIENT_TAIL <<inbound<< [id: 0xcdde5cbd, /127.0.0.1:55694 => /127.0.0.1:8090] :: MESSAGE [StompMessage: headers={subscription=subscription-0, content-length=17, message-id=localhost-21, receipt=receipt-0, destination=/topic/SOME_TOPIC}

Java STOMP client can leave pipes open

I ran into this issue using the STOMP client monitored with a heartbeat from the server. When a heartbeat isn't received for a certain period, I was calling disconnect() before reconnecting with connect().

Disconnection would time out, and somewhere, possibly in the ClientBootstrap, pipes were left open. A new connect() call recreates the bootstrap object and opens new pipes. If the server was un-reachable and connect() was called indefinitely, eventually the application would run into a too many open files/sockets exception.

Interestingly, I created a reconnect() method which performs similar to connect() but without creating new ClientBootstrap and ChannelPipelineFactory objects and this manages to re-establish a connection without opening more pipes.

Unfortunately I'm not too familiar with netty so I'm not really sure why the disconnection process isn't cleaning up properly before the bootstrap object is set to null.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.