Re: Issue with network of brokers and active/passive pair

2024-02-28 Thread Matt Pavlovich
You are welcome =)

failover - client side to support auto-reconnect to one or more brokers due to 
connection drop

masterslave - broker side to support exactly your architecture. Moving messages 
to one of a group of brokers where there is one active and one or more failover 
brokers

Matt Pavlovich

> On Feb 28, 2024, at 12:00 AM, Bruce Cooper  wrote:
> 
> Hi Matt,
> 
> Thank you sooo much for answering my question.  That simple config change 
> fixed the problem!  I’m so grateful
> 
> Out of curiosity, the documentation mentions
> 
> but there are a some other non-intuitive options that must be configured for 
> it to work as desired
> 
> For my own edification, is there any explanation anywhere of the differences 
> between failover and masterslave?  I’d be curious to understand how it works.
> 
> Thanks again.
> 
> 
> 
> 
>> On 28 Feb 2024, at 10:58 am, Matt Pavlovich  wrote:
>> 
>> Hi Bruce-
>> 
>> Network Connectors retry or ‘failover’ automatically, so you should don’t 
>> use the ‘failover’ transport in your networkConnector uri.
>> 
>> The networkConnector uri scheme you are looking for in this architecture is 
>> ‘masterslave’:
>> 
>> https://activemq.apache.org/components/classic/documentation/networks-of-brokers
>> 
>> Thanks,
>> Matt Pavlovich
>> 
>>> On Feb 22, 2024, at 8:20 PM, Bruce Cooper  wrote:
>>> 
>>> "static:failover:
>> 
> 



Re: Issue with network of brokers and active/passive pair

2024-02-27 Thread Bruce Cooper
Hi Matt,

Thank you sooo much for answering my question.  That simple config change fixed 
the problem!  I’m so grateful

Out of curiosity, the documentation mentions

but there are a some other non-intuitive options that must be configured for it 
to work as desired

For my own edification, is there any explanation anywhere of the differences 
between failover and masterslave?  I’d be curious to understand how it works.

Thanks again.




> On 28 Feb 2024, at 10:58 am, Matt Pavlovich  wrote:
> 
> Hi Bruce-
> 
> Network Connectors retry or ‘failover’ automatically, so you should don’t use 
> the ‘failover’ transport in your networkConnector uri.
> 
> The networkConnector uri scheme you are looking for in this architecture is 
> ‘masterslave’:
> 
> https://activemq.apache.org/components/classic/documentation/networks-of-brokers
> 
> Thanks,
> Matt Pavlovich
> 
>> On Feb 22, 2024, at 8:20 PM, Bruce Cooper  wrote:
>> 
>> "static:failover:
> 



Re: Issue with network of brokers and active/passive pair

2024-02-27 Thread Matt Pavlovich
Hi Bruce-

Network Connectors retry or ‘failover’ automatically, so you should don’t use 
the ‘failover’ transport in your networkConnector uri.

The networkConnector uri scheme you are looking for in this architecture is 
‘masterslave’:

https://activemq.apache.org/components/classic/documentation/networks-of-brokers

Thanks,
Matt Pavlovich

> On Feb 22, 2024, at 8:20 PM, Bruce Cooper  wrote:
> 
> "static:failover:



Re: Issue with network of brokers and active/passive pair

2024-02-26 Thread Bruce Cooper
Hi Marco,

Thanks for checking back in.

from pom.xml


org.apache.activemq
activemq-client
5.15.8


org.apache.activemq
activemq-pool
5.15.8



The server is 5.17.6

When you asked this, I realised my dependencies were kind of old, so I
updated it to


jakarta.jms
jakarta.jms-api
3.1.0




org.apache.activemq
activemq-client
6.0.1


ported my imports to jakarta.jms, and re-ran.  I still get the same result.
It works for NON_PERSISTENT, it does not for PERSISTENT messages.


On Mon, 26 Feb 2024 at 16:54, Marco Garavello
 wrote:

> Hello Bruce,
>
> thanks for sharing precise info
> That sounds really very strange and sounds like a bug of AMQ (or a
> configuration issue).
> A question, maybe trivial: which version of AMQ jar library are you using
> on your Java producer?
>
>
> *Distinti Saluti / *Kind Regards
> M.G.
>
>
>
> Il giorno lun 26 feb 2024 alle ore 05:08 Bruce Cooper <
> br...@mechination.com.au> ha scritto:
>
> > Now I have to rescind my previous comments.  It runs out NON_PERSISTENT
> > messages from clients or the browser console are forwarded and consumed
> > correctly, but PERSISTENT messages are not transmitted correctly.  This
> is
> > true whether I send from the console, from JAVA using the JMS/OpenWire
> > client or from Javascript rhea/AMQP.  I have turned on TRACE logging on
> the
> > servers, but do not see any hints.
> >
> > Any suggestions?  I saw that Herbert suggested I had only set up two
> > parallel brokers, but I followed the instructions at
> >
> >
> https://urldefense.com/v3/__https://activemq.apache.org/components/classic/documentation/shared-file-system-master-slave__;!!Ck4v2Rc!kCJ7o6_l-zIBD-UBlJOFj6X_R52z-t95TS3L_Cd175LwuDgk0_1ZAOfTLPv7spvhXcll_c6yLN8WY1oHFIZc52E$
> >
> >
> >
> >
> > On Mon, 26 Feb 2024 at 10:00, Bruce Cooper 
> > wrote:
> >
> > > As a follow up, I can now confirm that using a different client (an
> AMQP
> > > client written in javascript using the rhea library) works as expected.
> > It
> > > is just this Java process that is broken.  Any assistance you can
> provide
> > > would be greatly appreciated.
> > >
> > > On Mon, 26 Feb 2024 at 09:21, Bruce Cooper 
> > > wrote:
> > >
> > >> Hi Marco,
> > >>
> > >> Thanks for your response.  I agree it is strange.  I now have some
> more
> > >> information to share.  It now looks like it has something to do with
> my
> > >> message producer, rather than core ActiveMQ behaviour.
> > >>
> > >> If I send messages using the ActiveMQ console on Broker A, they are
> > >> transmitted and received correctly by the receiver.  If I send
> messages
> > >> using the attached program, it only works until the failover happens.
> > What
> > >> is super strange is that the producer isn't connecting to the failover
> > pair
> > >> (B and C).  It is connected to the satellite (A).  Furthermore, that
> > >> process is ephemeral.  It is restarted each time a send is made.
> > >>
> > >> My test is now a bit different than before. I first setup the brokers,
> > >> and initiate a "failover"
> > >>
> > >>1. Start Brokers B and C configured to use the same data directory
> so
> > >>that they are in a failover configuration.  Note that B is acting
> as
> > the
> > >>primary, and C is in standby
> > >>2. Start Broker A, configured to point to Brokers B and C via the
> > >>connection string static:failover:(tcp://100.127.41.128:61616
> ,tcp://
> > >>100.127.41.128:61617). Note that it connects to B
> > >>3. Start consumer to consume from Brokers B and C using the same
> > >>failover connection string. Note that it connects to B (in this
> > example)
> > >>4. Start producer to send to broker A.  Note that messages are
> > >>received by the consumer.  Repeat to confirm that this continues to
> > operate.
> > >>5. Send a message using the console, and note that this also works.
> > >>6. Stop Broker B.  Wait for both Broker A and the consumer to
> > >>reconnect to C, once it has obtained its locks and started.
> > >>
> > >> Once failover has occurred, proving that sending from the console
> still
> > >> works:
> > >>
> > >>1. Connect all processes together, do a failover, and wait for
> > >>reconnection
> > >>2. Send message in Broker A's Console, on the queue page
> > >>3. Message is received by consumer
> > >>4. See Enqueued and Dequeued metric go up (after a browser
> refresh) -
> > >>This indicates that the message has been dequeued by the network
> > connection
> > >>and forwarded on to the HA pair.
> > >>5. Check the console on Broker C and note that its enqueue and
> > >>dequeue count have incremented.
> > >>
> > >> The above shows everything works as expected, now let us try my
> producer
> > >> program
> > >>
> > >>1. Run the main program below with argument "send" - This connects
> to
> > >>the satellite broker (Broker A) and publishes a message
> > >>2. Note that no message is received by the consumer connected to C
> > >>(once the 

Re: Issue with network of brokers and active/passive pair

2024-02-26 Thread Marco Garavello
Hello Bruce,

thanks for sharing precise info
That sounds really very strange and sounds like a bug of AMQ (or a
configuration issue).
A question, maybe trivial: which version of AMQ jar library are you using
on your Java producer?


*Distinti Saluti / *Kind Regards
M.G.



Il giorno lun 26 feb 2024 alle ore 05:08 Bruce Cooper <
br...@mechination.com.au> ha scritto:

> Now I have to rescind my previous comments.  It runs out NON_PERSISTENT
> messages from clients or the browser console are forwarded and consumed
> correctly, but PERSISTENT messages are not transmitted correctly.  This is
> true whether I send from the console, from JAVA using the JMS/OpenWire
> client or from Javascript rhea/AMQP.  I have turned on TRACE logging on the
> servers, but do not see any hints.
>
> Any suggestions?  I saw that Herbert suggested I had only set up two
> parallel brokers, but I followed the instructions at
>
> https://urldefense.com/v3/__https://activemq.apache.org/components/classic/documentation/shared-file-system-master-slave__;!!Ck4v2Rc!kCJ7o6_l-zIBD-UBlJOFj6X_R52z-t95TS3L_Cd175LwuDgk0_1ZAOfTLPv7spvhXcll_c6yLN8WY1oHFIZc52E$
>
>
>
>
> On Mon, 26 Feb 2024 at 10:00, Bruce Cooper 
> wrote:
>
> > As a follow up, I can now confirm that using a different client (an AMQP
> > client written in javascript using the rhea library) works as expected.
> It
> > is just this Java process that is broken.  Any assistance you can provide
> > would be greatly appreciated.
> >
> > On Mon, 26 Feb 2024 at 09:21, Bruce Cooper 
> > wrote:
> >
> >> Hi Marco,
> >>
> >> Thanks for your response.  I agree it is strange.  I now have some more
> >> information to share.  It now looks like it has something to do with my
> >> message producer, rather than core ActiveMQ behaviour.
> >>
> >> If I send messages using the ActiveMQ console on Broker A, they are
> >> transmitted and received correctly by the receiver.  If I send messages
> >> using the attached program, it only works until the failover happens.
> What
> >> is super strange is that the producer isn't connecting to the failover
> pair
> >> (B and C).  It is connected to the satellite (A).  Furthermore, that
> >> process is ephemeral.  It is restarted each time a send is made.
> >>
> >> My test is now a bit different than before. I first setup the brokers,
> >> and initiate a "failover"
> >>
> >>1. Start Brokers B and C configured to use the same data directory so
> >>that they are in a failover configuration.  Note that B is acting as
> the
> >>primary, and C is in standby
> >>2. Start Broker A, configured to point to Brokers B and C via the
> >>connection string static:failover:(tcp://100.127.41.128:61616,tcp://
> >>100.127.41.128:61617). Note that it connects to B
> >>3. Start consumer to consume from Brokers B and C using the same
> >>failover connection string. Note that it connects to B (in this
> example)
> >>4. Start producer to send to broker A.  Note that messages are
> >>received by the consumer.  Repeat to confirm that this continues to
> operate.
> >>5. Send a message using the console, and note that this also works.
> >>6. Stop Broker B.  Wait for both Broker A and the consumer to
> >>reconnect to C, once it has obtained its locks and started.
> >>
> >> Once failover has occurred, proving that sending from the console still
> >> works:
> >>
> >>1. Connect all processes together, do a failover, and wait for
> >>reconnection
> >>2. Send message in Broker A's Console, on the queue page
> >>3. Message is received by consumer
> >>4. See Enqueued and Dequeued metric go up (after a browser refresh) -
> >>This indicates that the message has been dequeued by the network
> connection
> >>and forwarded on to the HA pair.
> >>5. Check the console on Broker C and note that its enqueue and
> >>dequeue count have incremented.
> >>
> >> The above shows everything works as expected, now let us try my producer
> >> program
> >>
> >>1. Run the main program below with argument "send" - This connects to
> >>the satellite broker (Broker A) and publishes a message
> >>2. Note that no message is received by the consumer connected to C
> >>(once the failover has occurred)
> >>3. Note that Broker A's console queue page again, and see that the
> >>Enqueued and Dequeued metric have incremented as before.
> >>4. Check the broker C queue console page, and note that this time the
> >>Enqueued and Dequeued metric have _not_ been incremented.  It is as
> if A
> >>thinks it has sent the message, but the pair C never receives it.
> >>
> >> I feel like I must have misconfigured my producer code in some fashion,
> >> but it was simply based on examples I found.  Is there something
> obvious I
> >> have missed?
> >>
> >>
> >> package au.com.mechination.integ.test;
> >>
> >> import java.util.Date;
> >>
> >> import javax.jms.Connection;
> >> import javax.jms.DeliveryMode;
> >> import 

Re: Issue with network of brokers and active/passive pair

2024-02-25 Thread Bruce Cooper
Now I have to rescind my previous comments.  It runs out NON_PERSISTENT
messages from clients or the browser console are forwarded and consumed
correctly, but PERSISTENT messages are not transmitted correctly.  This is
true whether I send from the console, from JAVA using the JMS/OpenWire
client or from Javascript rhea/AMQP.  I have turned on TRACE logging on the
servers, but do not see any hints.

Any suggestions?  I saw that Herbert suggested I had only set up two
parallel brokers, but I followed the instructions at
https://activemq.apache.org/components/classic/documentation/shared-file-system-master-slave




On Mon, 26 Feb 2024 at 10:00, Bruce Cooper  wrote:

> As a follow up, I can now confirm that using a different client (an AMQP
> client written in javascript using the rhea library) works as expected.  It
> is just this Java process that is broken.  Any assistance you can provide
> would be greatly appreciated.
>
> On Mon, 26 Feb 2024 at 09:21, Bruce Cooper 
> wrote:
>
>> Hi Marco,
>>
>> Thanks for your response.  I agree it is strange.  I now have some more
>> information to share.  It now looks like it has something to do with my
>> message producer, rather than core ActiveMQ behaviour.
>>
>> If I send messages using the ActiveMQ console on Broker A, they are
>> transmitted and received correctly by the receiver.  If I send messages
>> using the attached program, it only works until the failover happens.  What
>> is super strange is that the producer isn't connecting to the failover pair
>> (B and C).  It is connected to the satellite (A).  Furthermore, that
>> process is ephemeral.  It is restarted each time a send is made.
>>
>> My test is now a bit different than before. I first setup the brokers,
>> and initiate a "failover"
>>
>>1. Start Brokers B and C configured to use the same data directory so
>>that they are in a failover configuration.  Note that B is acting as the
>>primary, and C is in standby
>>2. Start Broker A, configured to point to Brokers B and C via the
>>connection string static:failover:(tcp://100.127.41.128:61616,tcp://
>>100.127.41.128:61617). Note that it connects to B
>>3. Start consumer to consume from Brokers B and C using the same
>>failover connection string. Note that it connects to B (in this example)
>>4. Start producer to send to broker A.  Note that messages are
>>received by the consumer.  Repeat to confirm that this continues to 
>> operate.
>>5. Send a message using the console, and note that this also works.
>>6. Stop Broker B.  Wait for both Broker A and the consumer to
>>reconnect to C, once it has obtained its locks and started.
>>
>> Once failover has occurred, proving that sending from the console still
>> works:
>>
>>1. Connect all processes together, do a failover, and wait for
>>reconnection
>>2. Send message in Broker A's Console, on the queue page
>>3. Message is received by consumer
>>4. See Enqueued and Dequeued metric go up (after a browser refresh) -
>>This indicates that the message has been dequeued by the network 
>> connection
>>and forwarded on to the HA pair.
>>5. Check the console on Broker C and note that its enqueue and
>>dequeue count have incremented.
>>
>> The above shows everything works as expected, now let us try my producer
>> program
>>
>>1. Run the main program below with argument "send" - This connects to
>>the satellite broker (Broker A) and publishes a message
>>2. Note that no message is received by the consumer connected to C
>>(once the failover has occurred)
>>3. Note that Broker A's console queue page again, and see that the
>>Enqueued and Dequeued metric have incremented as before.
>>4. Check the broker C queue console page, and note that this time the
>>Enqueued and Dequeued metric have _not_ been incremented.  It is as if A
>>thinks it has sent the message, but the pair C never receives it.
>>
>> I feel like I must have misconfigured my producer code in some fashion,
>> but it was simply based on examples I found.  Is there something obvious I
>> have missed?
>>
>>
>> package au.com.mechination.integ.test;
>>
>> import java.util.Date;
>>
>> import javax.jms.Connection;
>> import javax.jms.DeliveryMode;
>> import javax.jms.Destination;
>> import javax.jms.JMSException;
>> import javax.jms.Message;
>> import javax.jms.MessageConsumer;
>> import javax.jms.MessageProducer;
>> import javax.jms.Session;
>> import javax.jms.TextMessage;
>>
>> import org.apache.activemq.ActiveMQConnectionFactory;
>> import org.slf4j.Logger;
>> import org.slf4j.LoggerFactory;
>>
>> /**
>> * Hello world!
>> *
>> */
>> public class Main {
>> Connection conn = null;
>> ActiveMQConnectionFactory connectionFactory;
>> private Session session;
>>
>> static final Logger logger = LoggerFactory.getLogger(Main.class);
>>
>> public static void main(String[] args) throws JMSException {
>> Main doer = 

Re: Issue with network of brokers and active/passive pair

2024-02-25 Thread Bruce Cooper
As a follow up, I can now confirm that using a different client (an AMQP
client written in javascript using the rhea library) works as expected.  It
is just this Java process that is broken.  Any assistance you can provide
would be greatly appreciated.

On Mon, 26 Feb 2024 at 09:21, Bruce Cooper  wrote:

> Hi Marco,
>
> Thanks for your response.  I agree it is strange.  I now have some more
> information to share.  It now looks like it has something to do with my
> message producer, rather than core ActiveMQ behaviour.
>
> If I send messages using the ActiveMQ console on Broker A, they are
> transmitted and received correctly by the receiver.  If I send messages
> using the attached program, it only works until the failover happens.  What
> is super strange is that the producer isn't connecting to the failover pair
> (B and C).  It is connected to the satellite (A).  Furthermore, that
> process is ephemeral.  It is restarted each time a send is made.
>
> My test is now a bit different than before. I first setup the brokers, and
> initiate a "failover"
>
>1. Start Brokers B and C configured to use the same data directory so
>that they are in a failover configuration.  Note that B is acting as the
>primary, and C is in standby
>2. Start Broker A, configured to point to Brokers B and C via the
>connection string static:failover:(tcp://100.127.41.128:61616,tcp://
>100.127.41.128:61617). Note that it connects to B
>3. Start consumer to consume from Brokers B and C using the same
>failover connection string. Note that it connects to B (in this example)
>4. Start producer to send to broker A.  Note that messages are
>received by the consumer.  Repeat to confirm that this continues to 
> operate.
>5. Send a message using the console, and note that this also works.
>6. Stop Broker B.  Wait for both Broker A and the consumer to
>reconnect to C, once it has obtained its locks and started.
>
> Once failover has occurred, proving that sending from the console still
> works:
>
>1. Connect all processes together, do a failover, and wait for
>reconnection
>2. Send message in Broker A's Console, on the queue page
>3. Message is received by consumer
>4. See Enqueued and Dequeued metric go up (after a browser refresh) -
>This indicates that the message has been dequeued by the network connection
>and forwarded on to the HA pair.
>5. Check the console on Broker C and note that its enqueue and dequeue
>count have incremented.
>
> The above shows everything works as expected, now let us try my producer
> program
>
>1. Run the main program below with argument "send" - This connects to
>the satellite broker (Broker A) and publishes a message
>2. Note that no message is received by the consumer connected to C
>(once the failover has occurred)
>3. Note that Broker A's console queue page again, and see that the
>Enqueued and Dequeued metric have incremented as before.
>4. Check the broker C queue console page, and note that this time the
>Enqueued and Dequeued metric have _not_ been incremented.  It is as if A
>thinks it has sent the message, but the pair C never receives it.
>
> I feel like I must have misconfigured my producer code in some fashion,
> but it was simply based on examples I found.  Is there something obvious I
> have missed?
>
>
> package au.com.mechination.integ.test;
>
> import java.util.Date;
>
> import javax.jms.Connection;
> import javax.jms.DeliveryMode;
> import javax.jms.Destination;
> import javax.jms.JMSException;
> import javax.jms.Message;
> import javax.jms.MessageConsumer;
> import javax.jms.MessageProducer;
> import javax.jms.Session;
> import javax.jms.TextMessage;
>
> import org.apache.activemq.ActiveMQConnectionFactory;
> import org.slf4j.Logger;
> import org.slf4j.LoggerFactory;
>
> /**
> * Hello world!
> *
> */
> public class Main {
> Connection conn = null;
> ActiveMQConnectionFactory connectionFactory;
> private Session session;
>
> static final Logger logger = LoggerFactory.getLogger(Main.class);
>
> public static void main(String[] args) throws JMSException {
> Main doer = new Main();
>
> if (args.length > 0 && args[0].equals("send")) {
> doer.send();
> } else {
> doer.receive();
> }
> }
>
> public void connect(String url, String username, String password)
> throws JMSException {
> final ActiveMQConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory(url);
>
> // Pass the sign-in credentials.
> connectionFactory.setUserName(username);
> connectionFactory.setPassword(password);
>
> // Establish a connection for the producer.
> this.conn = connectionFactory.createConnection();
> conn.start();
>
> session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
> }
>
> void send() throws JMSException {
>  

Re: Issue with network of brokers and active/passive pair

2024-02-25 Thread Bruce Cooper
Hi Marco,

Thanks for your response.  I agree it is strange.  I now have some more
information to share.  It now looks like it has something to do with my
message producer, rather than core ActiveMQ behaviour.

If I send messages using the ActiveMQ console on Broker A, they are
transmitted and received correctly by the receiver.  If I send messages
using the attached program, it only works until the failover happens.  What
is super strange is that the producer isn't connecting to the failover pair
(B and C).  It is connected to the satellite (A).  Furthermore, that
process is ephemeral.  It is restarted each time a send is made.

My test is now a bit different than before. I first setup the brokers, and
initiate a "failover"

   1. Start Brokers B and C configured to use the same data directory so
   that they are in a failover configuration.  Note that B is acting as the
   primary, and C is in standby
   2. Start Broker A, configured to point to Brokers B and C via the
   connection string static:failover:(tcp://100.127.41.128:61616,tcp://
   100.127.41.128:61617). Note that it connects to B
   3. Start consumer to consume from Brokers B and C using the same
   failover connection string. Note that it connects to B (in this example)
   4. Start producer to send to broker A.  Note that messages are received
   by the consumer.  Repeat to confirm that this continues to operate.
   5. Send a message using the console, and note that this also works.
   6. Stop Broker B.  Wait for both Broker A and the consumer to reconnect
   to C, once it has obtained its locks and started.

Once failover has occurred, proving that sending from the console still
works:

   1. Connect all processes together, do a failover, and wait for
   reconnection
   2. Send message in Broker A's Console, on the queue page
   3. Message is received by consumer
   4. See Enqueued and Dequeued metric go up (after a browser refresh) -
   This indicates that the message has been dequeued by the network connection
   and forwarded on to the HA pair.
   5. Check the console on Broker C and note that its enqueue and dequeue
   count have incremented.

The above shows everything works as expected, now let us try my producer
program

   1. Run the main program below with argument "send" - This connects to
   the satellite broker (Broker A) and publishes a message
   2. Note that no message is received by the consumer connected to C (once
   the failover has occurred)
   3. Note that Broker A's console queue page again, and see that the
   Enqueued and Dequeued metric have incremented as before.
   4. Check the broker C queue console page, and note that this time the
   Enqueued and Dequeued metric have _not_ been incremented.  It is as if A
   thinks it has sent the message, but the pair C never receives it.

I feel like I must have misconfigured my producer code in some fashion, but
it was simply based on examples I found.  Is there something obvious I have
missed?


package au.com.mechination.integ.test;

import java.util.Date;

import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Hello world!
*
*/
public class Main {
Connection conn = null;
ActiveMQConnectionFactory connectionFactory;
private Session session;

static final Logger logger = LoggerFactory.getLogger(Main.class);

public static void main(String[] args) throws JMSException {
Main doer = new Main();

if (args.length > 0 && args[0].equals("send")) {
doer.send();
} else {
doer.receive();
}
}

public void connect(String url, String username, String password) throws
JMSException {
final ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory(url);

// Pass the sign-in credentials.
connectionFactory.setUserName(username);
connectionFactory.setPassword(password);

// Establish a connection for the producer.
this.conn = connectionFactory.createConnection();
conn.start();

session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
}

void send() throws JMSException {
String url = "tcp://localhost:61616";
String username = "bruce";
String password = "sekrit";

System.out.println("Sender connecting to " + url);
connect(url, username, password);

// Create a queue named "MyQueue".
final Destination producerDestination = session.createQueue(
"TestQueue");

// Create a producer from the session to the queue.
final MessageProducer producer = session.createProducer
(producerDestination);

Re: Issue with network of brokers and active/passive pair

2024-02-23 Thread Marco Garavello
Hello Bruce,

that sounds very strange because with BrokerB stopped I understood that
everything is working good at the first subsequent run of the producer
script

"
*5. Run the producer script again.6. Observe that one set of messages is
delivered*"

while the issue appears at the following run

*7. Run the producer script again - This time no messages are delivered.*"

correct?


*Distinti Saluti / *Kind Regards
M.G.



Il giorno ven 23 feb 2024 alle ore 03:23 Bruce Cooper <
br...@mechination.com.au> ha scritto:

> Hi,
>
> I'm running into a strange issue configuring activemq 5.17.6 to forward
> messages from a satellite broker to a pair of brokers running in an
> active/passive (failover) pair.  I'm hoping somebody here can help me
>
> I have three brokers.  The first is running stand-alone, and is configured
> with a one way network bridge to the other two, who are operating in an
> active/passive (also known as master/slave) mode.
> /> Broker B. <---\
> Producer -> Broker A ---++ Consumer
> \> Broker C 
> This works fine, up until I try to test what happens when the redundant
> pair is rebooted/goes down.
>
> My test procedure is this:
>
>1. Start all brokers, and ensure that everything is connected
>2. Run the producer script multiple times to send persistent messages
>to a queue, seeing that messages are delivered to the consumer, and printed
>out.
>3. Shut down (via activemq stop cmd) the broker that the consumer is
>connected to (B)
>4. Observe that the consumer reconnects to the other broker (C), as
>does the satellite broker (A)
>5. Run the producer script again.
>6. Observe that one set of messages is delivered
>7. Run the producer script again - This time no messages are
>delivered.  Messages are  accepted by Broker A, and it seems that it has
>forwarded them to broker C (The queue shows the same number of enqueued and
>dequeued messages in Broker A's console, as does the Network Connector),
>but no messages (apart from the first set) appear in Broker C's queue.
>8. Get consumer to fail back to the original server (B) by restarting
>B, then stopping C
>9. Any subsequent attempts to send messages fail.
>10. Restart Broker A
>11. Messages now flow, but any that were transmitted at step 7 have
>been lost
>
>
> If I change the topology to remove Broker C and restart Broker B, messages
> are appropriately queued, forwarded and delivered to the consumer once it
> reconnects after the restart.  It behaves as expected.
>
> The configuration for the brokers is the default example configuration,
> except that Broker B and C use the same persistenceAdapter kahaDB directory
> and broker A has a network Connector that looks like
>
> 
> https://urldefense.com/v3/__http://100.127.41.128:61616__;!!Ck4v2Rc!ktRljP7TFoQII13jUiafX_0a7ZbVd33UDyll94Ekcn7YOxsD8Unos9-kNhPM_dGE40jWexQyddayxQnwfiehDhU$>
> ,tcp://100.127.41.128:61617
> 
> )" duplex="false" staticBridge="true" userName="bruce" password="sekrit"
> networkTTL="10">
> 
> 
> 
> 
> 
>
>
> I have attached the configuration files for reference, along with the test
> program I am using to send and receive.
>
> What am I doing wrong?
>
>
> --
> https://mechination.com.au/
> 
> Ph: 0448 341 729
>