Connect to SAP event mesh in java without using Spring - java

I am trying to connect my Java program to the SAP event mesh to listen on changes published to a topic/queue.
There are some limited examples on the web on how to do this, but they all use Spring.
I can't use Spring, so was wondering if anyone has some example Java code for connecting that does not use Spring. Something really simple with JMS, AMQP etc (I can add all the bells and whistles, I just need to get the connection working).
Also I need to connect using AMPQ over web sockets. Is there a nice Java library for that? Some JMS lib, Apache Camel, ..?
thanks
graham

Related

Implement web socket local server in Swing application

I am not able to find any implementation of a WS or WSS web socket server created in a Java Swing desktop application.
I am planning to govern multiple clients using a local server, imagine chat room on a local LAN, but I do not wish to host/run Tomcat or Jetty etc to host the server, I want it to be a Java Swing application that I can copy paste on any machine to make it the server and it can have the same chat features.
UPDATE:
Found some very useful topic : Java - Send Message to all Clients
Will follow this.
I am no expert in this realm, but this might help…
Wikipedia maintains a list of WebSocket implementations, both client and server.
You may be interested in the open-source Atmosphere Framework. It supports working with WebSocket but I am not clear if it actually is a server implementation.
Perhaps check open-source projects like Tomcat or Jetty or WildFly to see if their WebSocket implementation might be modularized sufficiently to plug into your app.

Post JMS message to Weblogic throught PHP

I have a web application that has communicate with other Java web application throught JMS in Weblogic.
I read this answer:
How to connect Jms from PHP ?
I installed ActiveMQ and tried to use it.
But in the Weblogic we need "JMS_FACTORY" and "QUEUE_NAME".
I think it use t3 protocol.
When I want to use is ActiveMQ, it needs tcp protocol.
for example:
$stomp = new \Stomp('tcp://10.x.x.x:9700');
Is that possible to push messages in the Weblogic queue?
I think you mix API, wire protocol and client vs server in your question.
WebLogic JMS builds on java constructs all the way from Client to Server. If you really really need queue support I guess you need to create a PHP extension (in C/C++) that uses WebLogic C API (which in turn is a Java bridge). Maybe not smooth or bug free.
The easy way is to write a small WebLogic app that receives messages over HTTP and posts them to a queue. Or, if you can't touch the WebLogic installation, create a Standalone java app that you connect to your PHP in whatever way (HTTP, STOMP, MQTT, memory grid, files, whatever)

Restful Webservice Java, server side

I'm trying to develop a small server which would include one restful webservice.
I'd like to use JAX-RS for the webservice part, but every example I'm seeing is using a tomcat server, and I can't use any 'application' server (meaning I can create a server in my code, but can't run it from the outside).
Well anyway I was wondering if anyone had any sample to show, and any advice on which light library I could use to run such a simple server into my code (can't use any gpl /lgpl etc licence, so no jersey for example).
Thank you.
It's possible to embed Tomcat in your application, see here for an example: http://java.dzone.com/articles/embedded-tomcat-minimal
Another popular choice for an embedded servlet container is Jetty, they have a tutorial here.
Edit
The examples provided with Jersey can also be helpful, here's one for running using the Grizzly HTTP library: https://github.com/jersey/jersey/blob/master/examples/helloworld/src/main/java/org/glassfish/jersey/examples/helloworld/App.java
You can even use the HTTP server that's bundled with the JDK (probably not the way to go for a real application): https://github.com/jersey/jersey/blob/master/examples/helloworld-pure-jax-rs/src/main/java/org/glassfish/jersey/examples/helloworld/jaxrs/App.java
Have you checked out http://www.sparkjava.com/?
It's very light-weight and concise.
Building a server into code is nothing. See "Embedding Jetty", for one. There are plenty of other options with varying degrees of difficulty and capabilities, like the Simple Framework, Tomcat, Grizzly, Netty, and Vert.x, to name a few. Then, if you're not stuck with Java, the language, there's Ratpack for a lightweight REST server. Otherwise, running something like Jersey in an embedded server is quite simple. I do it every day in tests.

Can I get access to the JMS on non-EE java?

As the title states, I want to use the JMS to interact with a queue server(rabbitmq and apollo, for testing) but I read that JMS is included in Java EE. Is there a library or way I can get access to it without EE? I am just using the standard JDK that comes with mac(I don't see the EE avail for mac on the download page).
A possible option would be to use the client library which is offered by RabbitMQ (http://www.rabbitmq.com/java-client.html).
This way you can simply connect to a RabbitMQ server/queue.
But I'm not sure if this library can be used to connect to other JMS implementations than RabbitMQ.

Can I use JMS with a regular (i.e not Java EE) Java Application?

I'd like to use the Java Message Service but it says it's for the Java EE Platform. Is there a way to port it to a regular Java application (which I'm working on in Eclipse)?
JMS is part of the Java EE spec, but you can use it from any Java application. Depending on your needs, you may have to run a standalone broker, but this is just like running a regular daemon (or Windows service).
Yes, you absolutely can use JMS from a J2SE application. In fact, you can access a JMS broker from programs not written in Java at all. The ActiveMQ JMS server includes several transport connectors. The connectors allow clients to interact with ActiveMQ using different communication protocols. Most Java clients use the openwire connector. I've written a PHP client that used the STOMP protocol with great success. It consumed messages sent to a JMS Queue by a Java application running in the Tomcat Servlet Container.
This is a much more complicated question than the answer would indicate. Jms is a spec. Really just a set of interfaces. You can absolutley use those interfaces from a standalone java process. Hell you could write your own jms compliant messaging implementation. Questions you should be asking yourself is what messaging implementation will i be using and does it support jms? Even after answering that there are numerous caveats to take into account when connecting to brokers outside of a container including but not limited to transactionality, load balancing, connection pooling, and high availability. You should be very clear about what your trying to do and what messaging vendor you are working with before you can answer this completely
Many Messaging servers also provides their java api for the communication like MQ, open source Apache ActiveMQ. In that case you don't realy need to worry about JMS. You simply need to understand and use that API.

Categories