mrstampy / stampy Goto Github PK
View Code? Open in Web Editor NEWJava implementation of the STOMP 1.2 specification
Java implementation of the STOMP 1.2 specification
I tried running
git clone https://github.com/mrstampy/Stampy.git stampy
and got nothing but images/html from the webpage on github? Am I doing something wrong??
I've opened a StackOverflow question here:
http://stackoverflow.com/questions/31627819/stampy-variations-on-stomp-protocol
I thought the STOMP protocol was standardised. So I don't understand the reference to Mina and Netty and why there isn't a "de-facto" client in the examples.
Can you please elaborate on whether this is a difference in the protocol? If I'm, say, connecting to a RabbitMQ STOMP server, does it matter which client RI I choose to use?
Is it possible to have an example which doesn't use Mina and Netty?
When trying to implement the example code I find that
gateway.connect();
is needed , but I suspect this is not all, I have to Thread.sleep(...) for an unspecified amount of time before it is actually connected, I guess I need to respond to some callback?
Issue
Although Stampy targets 1.5 in it's build, the 1.7 API is used by Stampy. For example AbstractStampyMessageGateway
makes use of java.lang.invoke.MethodHandles
which is new in Java 7. Though closer inspection it looks like any class which is logging is using java.lang.invoke.MethodHandles
to reflect the class object. Thus when attempting to run a Stampy server on a JVM of lesser vintage that 1.7 you experience a NoClassDefFoundError
exception which looks like the following on a 1.6 JVM:
java.lang.NoClassDefFoundError: java/lang/invoke/MethodHandles
at asia.stampy.common.gateway.AbstractStampyMessageGateway.<clinit>(AbstractStampyMessageGateway.java:51)
...
Caused by: java.lang.ClassNotFoundException: java.lang.invoke.MethodHandles
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
...
Solution 1
Replace "Java 5 compatible" in the documentation with "Java 7 only" and stop targeting 1.5 for no reason.
Solution 2
Replace usages of the 1.7 API with 1.5 compatible equivalents. For example:
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
// Should be replaced by
private static final Logger log = LoggerFactory.getLogger(AbstractStampyMessageGateway.class);
IDontNeedSecurity class does not exist.
If I try to create one similar I get
Exception in thread "main" asia.stampy.common.gateway.StampySecurityException: An instance of SecurityMinaMessageListener has not been configured first in the list of StampyMinaMessageListeners
I'm using the netty interfaces.
Also I can't see SUBSCRIBE and UNSUBSCRIBE messages??
I'm trying to build a RabbitMQ-Webstomp system behind Apache mod-wstunnel. This allows us to turn any websocket host:port combination (e.g. localhost:61613) to an apache URI https://server/myhiddenmq and therefore work with Stomp in situations where all but the most minimal ports are blocked.
However, Stampy appears only to use the HostPort class. This doesn't seem to accept a path, or protocol, or anything else.
Is there a technical requirement only to specify connections with Host:Port combinations?
Would it be a worthy fork for me to attempt to turn all the HostPort usage to URI?
If a message doesn't have a body (e.g., "CONNECT"), toStompMessage includes the text "null" in the String.
The line "builder.append(body);" should be surrounded with a null check.
When trying to implement the example code I find that
gateway.connect();
is needed , but I suspect this is not all, I have to Thread.sleep(...) for an unspecified amount of time before it is actually connected, I guess I need to respond to some callback?
When the message listener is fired stampy has removed all the '\n' characters from the message body.
I am not an expert with Ivy but I had trouble with building a freshly checked out copy of the software.
In build.xml
is the target
<target name="resolve">
<ivy:resolve file="${basedir}/ivy.xml"/>
</target>
As I understand it, ivy:resolve
downloads and resolves the deps into its cache directory. The task should be ivy:retrieve
which resolves and then copies the files into the project's lib directory.
Does stampy support TLS connections to a STOMP server? If so, can you post an example?
Have you considered supporting STOMP over websockets, which most AMQP/STOMP brokers are starting to support? For Java apps integrating over the open internet, running stomp over websockets/wss on standard ports 80/443 is a nice solution that is ISP friendly...
To avoid boilerplate code in client/server configuration, something like:
AbstractStampyMessageGateway gw = new GatewayBuilder().
withHost(3456).
withHeartbeat(1000).
add(listener1).
add(listener2).
build()
This pattern is also common for Netty internals.
Can you please provide an example of how to get messages from a queue?
In AbstractAcknowledgementListenerAndInterceptor.java
, interceptMessage
, there is this line:
String ack = msg.getHeader().getAck();
That getAck()
value is added to the queue as the identifier of the message, but shouldn't it be getId()
instead? getAck
returns auto
, client
or client-individual
.
Here's the current implementation:
public void interceptMessage(StampyMessage<?> message, HostPort hostPort) throws InterceptException {
MessageMessage msg = (MessageMessage) message;
String ack = msg.getHeader().getAck();
Queue<String> queue = messages.get(hostPort);
if (queue == null) {
queue = new ConcurrentLinkedQueue<String>();
messages.put(hostPort, queue);
}
queue.add(ack);
startTimerTask(hostPort, ack);
}
Now, when a method like evaluateAck
uses the id
header to look up the message in the queue, yet it will never find the message:
private void evaluateAck(AckHeader header, HostPort hostPort) throws Exception {
String id = header.getId();
if (hasMessageAck(id, hostPort)) {
clearMessageAck(id, hostPort);
getHandler().ackReceived(id, header.getReceipt(), header.getTransaction());
} else {
throw new UnexpectedAcknowledgementException("No ACK message expected, yet received id " + id + " from "
+ hostPort);
}
}
private boolean hasMessageAck(String messageId, HostPort hostPort) {
Queue<String> ids = messages.get(hostPort);
if (ids == null || ids.isEmpty()) return false;
return ids.contains(messageId);
}
Hi,
I have downloaded the zip and trying to setup the server.
but it requires a lot of external jars.
can you specify a list of the jars (preferably with download links) ?
can you provide a setup guide to run as java server application ?
Thanks
Your help much appreciated.
Ido H
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.