koool
koool

Reputation: 15517

Adding notification push from Mysql server to Java application

Hi I have designed a desktop application in Java SE with netbeans and Mysql.I do not have any server coding for now since all my operations were of pull type. I need a push notification functionality. Previously I had a button that refreshed the notification but now I want the notifications to be updated automatically.

What would be best way to add this functionality without changing much of my present code.

Any help appreciated. Thanks a lot

Upvotes: 0

Views: 1388

Answers (1)

chubbsondubs
chubbsondubs

Reputation: 38706

You really will have to change a lot about your architecture to have your application go the other direction. However, I think the best approach is to use a light weight JMS provider. That way your client can code to the JMS API which is really pretty straight forward, and your server can use JMS and its really pretty easy. It's not nearly as much effort as plumbing other options in.

The harder part is setting up the container in your application. It's not tremendously hard, but JMS has lots of options for configuration. Figuring out the point to point vs topic, durable vs non-durable and what's right for your application is a lot of research you have to do if you haven't done JMS before.

But, what this affords you is a very expressive control over messaging in your application. You can under the covers without modifying your code swap between polling or direct connections, message 1:1 or 1:many. If you need to send a message to one client vs. sending a message to all clients. You can segment messages between clients and create groups. Your messages can be durable or non-durable (survive client shutdown or server shutdown). The possibilities are endless, but you have to make a lot of architectural decisions. You also don't have to handle network topology and connectivity issues as much than if you used UDP multicast or TCP connections in reverse.

ActiveMQ and RabbitMQ can be easily embedded within a server using spring in a matter of 20 minutes. They also provide hooks for other platforms. It might sound overkill, but I've tried to do without JMS in the past when I should've used it and regretted not using it.

Upvotes: 1

Related Questions