and add depending:Copy Source | Copy HTML < repository > < id > jboss </ id > < name > jboss </ name > < url > http://repository.jboss.com/maven2 </ url > < snapshots > < enabled > false </ enabled > </ snapshots > </ repository >
Copy Source | Copy HTML < repository > < id > jboss </ id > < name > jboss </ name > < url > http://repository.jboss.com/maven2 </ url > < snapshots > < enabled > false </ enabled > </ snapshots > </ repository >
Copy Source | Copy HTML < repository > < id > jboss </ id > < name > jboss </ name > < url > http://repository.jboss.com/maven2 </ url > < snapshots > < enabled > false </ enabled > </ snapshots > </ repository >
Copy Source | Copy HTML < repository > < id > jboss </ id > < name > jboss </ name > < url > http://repository.jboss.com/maven2 </ url > < snapshots > < enabled > false </ enabled > </ snapshots > </ repository >
Copy Source | Copy HTML < repository > < id > jboss </ id > < name > jboss </ name > < url > http://repository.jboss.com/maven2 </ url > < snapshots > < enabled > false </ enabled > </ snapshots > </ repository >
Copy Source | Copy HTML < repository > < id > jboss </ id > < name > jboss </ name > < url > http://repository.jboss.com/maven2 </ url > < snapshots > < enabled > false </ enabled > </ snapshots > </ repository >
Copy Source | Copy HTML < repository > < id > jboss </ id > < name > jboss </ name > < url > http://repository.jboss.com/maven2 </ url > < snapshots > < enabled > false </ enabled > </ snapshots > </ repository >
Copy Source | Copy HTML < repository > < id > jboss </ id > < name > jboss </ name > < url > http://repository.jboss.com/maven2 </ url > < snapshots > < enabled > false </ enabled > </ snapshots > </ repository >
Copy Source | Copy HTML < repository > < id > jboss </ id > < name > jboss </ name > < url > http://repository.jboss.com/maven2 </ url > < snapshots > < enabled > false </ enabled > </ snapshots > </ repository >
Copy Source | Copy HTML
- < dependency >
- < groupId > jgroups </ groupId >
- < artifactId > jgroups </ artifactId >
- < version > 2.6.13.GA </ version >
- </ dependency >
- < dependency >
- < groupId > commons-logging </ groupId >
- < artifactId > commons-logging </ artifactId >
- < version > 1.1.1 </ version >
- </ dependency >
route add -net 224.0.0.0 netmask 240.0.0.0 dev lo
JChannel channel = new JChannel( "UDP(bind_addr=127.0.0.1)" );
channel.connect( "MyCluster" );
new Message( null, null, "Some content" )
channel.send( new Message( null, null, "Some content" ) )
Here, in order to reduce the amount of code, an object is inherited from the ReceiverAdapter class, which provides empty implementations of various Receiver interface methods. As you can see from the example, the receive method is used to process the message, to which the message is passed as a parameter.Copy Source | Copy HTML
- channel.setReceiver ( new ReceiverAdapter () {
- @Override
- public void receive ( Message m) {
- System. out .println (m.getObject ());
- }
- });
When run, this code should output something like:Copy Source | Copy HTML
- import java.io. BufferedReader ;
- import java.io. InputStreamReader ;
- import org.jgroups. JChannel ;
- import org.jgroups. Message ;
- import org.jgroups. ReceiverAdapter ;
- public class SimplestChat {
- public static void main ( String [] args) throws Exception {
- JChannel channel = new JChannel ( "UDP (bind_addr = 127.0.0.1)" );
- channel.setReceiver ( new ReceiverAdapter () {
- @Override
- public void receive ( Message m) {
- System. out .println (m.getObject ());
- }
- });
- channel.connect ( "MyCluster" ); // Connect to the group
- / ** <br/> * Command processing loop from the console <br/> * /
- BufferedReader in = new BufferedReader ( new InputStreamReader (System. In ));
- while ( true ) {
- String line = in .readLine ();
- if (line.equalsIgnoreCase ( "quit" ) || line.equalsIgnoreCase ( "exit" )) {
- break ;
- }
- channel.send ( new Message ( null , null , line));
- }
- channel.close (); // Disconnect from the group upon completion
- }
- }
Nov 8, 2009 4:18:27 PM org.jgroups.JChannel init INFO: JGroups version: 2.6.13.GA
Source: https://habr.com/ru/post/74660/
All Articles