• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

One computer sending a simple message to a second computer

 
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Have tried messaging before but never successful

I have two PC computers both running similar java programs

Computer 1: java program decides whether to trade on forex market or not and places a trade if required

Computer 2: shortened version of java program on Computer 1 - decides whether to trade AND then sends message to Computer 1 with its decision
[i.e. trade or NOT trade, and if trade whether to go short or long]

I am seeking a simple way to

a) have Computer 2 send a message to Computer 1
b) have Computer 1 receive that message

Any ideas ?
Bob M
 
Saloon Keeper
Posts: 5564
143
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do these machines know of one another? If they know each other's IP address, a socket connection would work.

I'm assuming that you don't want to involve a server of some kind.
 
Marshal
Posts: 64638
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you learn messaging from? Have you seen the Java™ Tutorials section?
 
Bob Matthews
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim.................

The machines are on the same network both connected by ethernet cable to the same router

Campbell............

I have tried understanding Active MQ etc. but I quickly get bogged down with the technical language
 
Master Rancher
Posts: 451
6
IntelliJ IDE Spring Fedora
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The link that Campbell posted is the most basic explanation of doing what you want. Actually one of the examples is sending stock quotes.
 
Tim Moores
Saloon Keeper
Posts: 5564
143
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bob Matthews wrote:The machines are on the same network both connected by ethernet cable to the same router


OK, so that makes it possible to use a direct connection like a socket. The question remains whether the codes do know the IP addresses of each other (or host names they can look up). If they do, sockets are not hard to implement, and the "All about sockets" section in the link Campbell posted will get you started. If they have no way of figuring out each other's IP address, a solution with an intermediary or registry (i.e., a server of some sort) would be necessary.

I have tried understanding Active MQ etc. but I quickly get bogged down with the technical language


ActiveMQ would imply a server; is that what you want? It sounded as if a direct connection was desired, but you didn't actually say whether or not a server-based solution was an option.
 
Bob Matthews
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Al....................

Sorry but can not see the example you suggest ???

Tim..................

I believe that the computers do know the other one's IP address
(both computers are running 24/7)

I don't know what options are available or what I want

Ideally:-

Computer 1 runs its java program to the point where it needs to receive a message from Computer 2
It waits at this point until a message is received

It then continues with the java program...........

This exercise happens hourly

Note messaging required to go one way only

Bob M
 
Marshal
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me just clarify things a bit: You really want your Java programs to communicate with each other. So saying you want the computers to communicate, that confuses the requirements a bit.

Anyway it seems like making the program which waits to receive messages into a server. In that case, ordinary low-level communication via sockets should be sufficient. Here's a link to a relevant tutorial: Lesson: All About Sockets.
 
Bob Matthews
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul

I find the discussion about sockets confusing...................

I have just read about JMS messaging service--- point to point
Maybe that would suffice

I guess I do not want to use an elephant to crack a nut

On reflection my requirements are a little more complicated:-

Computer 1 (the master computer) runs four different java programs simultaneously - each program handles a different current pair e.g. USD/JPY

It is the only computer which actually trades on the forex market

Computer 2 also runs four different java programs simultaneously - each program handles the same currency pair as one of the programs running on Computer 1

I require each program running on Computer 2 to send a message to the program on Computer 1 with the same currency pair

and all 8 programs update hourly

Bob M
 
Paul Clapham
Marshal
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bob Matthews wrote:I have just read about JMS messaging service--- point to point
Maybe that would suffice



You could do that too.
 
Bob Matthews
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I was using JMS messaging service Point-to-Point with 4 separate sessions simultaneously, how does one distinguish each session from the others ?

Bob M
 
Paul Clapham
Marshal
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You connect each session to one of the four queues you're going to configure.
 
Bob Matthews
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul...........

Would using a counter in each session be a sensible way for Computer 1 to know when it has received a message from its Computer 2 counterpart ?

Bob M
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!