Re: ActiveMQ artemis listener not working

2020-03-25 Thread rudra1in
Thanks brusdev, there is a problem in client making duplicate calls.



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html


Re: ActiveMQ artemis listener not working

2020-03-25 Thread Justin Bertram
Domenico is right. Using JmsTemplate will create a connection, session, &
producer for *every* message sent. This is a significant anti-pattern
discussed here [1] and here [2].


Justin

[1]
http://activemq.apache.org/components/artemis/documentation/latest/perf-tuning.html#avoiding-anti-patterns
[2] https://activemq.apache.org/jmstemplate-gotchas

On Wed, Mar 25, 2020 at 8:43 PM brusdev  wrote:

> Hi,
>
> the JmsTemplate creates a new session for each message to send, according
> to
> its source[1].
> So in the broker log you can find the lines relative the session creating
> and the message sending for each of the 5 messages sent by
> `sender.sendmessages`.
>
> [1]
>
> https://github.com/spring-projects/spring-framework/blob/v5.1.7.RELEASE/spring-jms/src/main/java/org/springframework/jms/core/JmsTemplate.java#L495
>
> Regards,
> Domenico
>
>
>
> --
> Sent from:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
>
>


Re: ActiveMQ artemis listener not working

2020-03-25 Thread brusdev
Hi,

the JmsTemplate creates a new session for each message to send, according to
its source[1].
So in the broker log you can find the lines relative the session creating
and the message sending for each of the 5 messages sent by
`sender.sendmessages`.

[1]
https://github.com/spring-projects/spring-framework/blob/v5.1.7.RELEASE/spring-jms/src/main/java/org/springframework/jms/core/JmsTemplate.java#L495

Regards,
Domenico



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html


Re: ActiveMQ artemis listener not working

2020-03-25 Thread rudra1in
I want to use embedded artemis MQ
I have one sender class and one listner tied to one queue.
import java.util.Date;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;

public class AddRequestSender {

 @Autowired
 JmsTemplate testTemplate;
 @Autowired
  ActiveMQConnectionFactory jmsConnectionFactory;
 private static final Logger LOGGER =
LoggerFactory.getLogger(AddRequestSender.class);

public AddRequestSender() {

}

  public void sendMessages(String string) throws JMSException,
InterruptedException {
  StringBuilder payload = null;
 
  for (int i = 0; i < 5; ++i) {
  payload = new StringBuilder();
  payload.append("Message [").append(i).append("] sent at:
").append(new Date());
  final String payload1= payload.toString();
  final int j = i;
  
  testTemplate.send("testQUeue",new MessageCreator() {
  public Message createMessage(Session session) throws
JMSException {
//  
  TextMessage message = session.createTextMessage();
  message.setText(payload1);
  message.setIntProperty("messageCount", j);
  return message;
  }
  });
   
  }
  
}

}

My listener class
import java.util.concurrent.atomic.AtomicInteger;

import javax.jms.Message;
import javax.jms.MessageListener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;



public class AddRequestQueueListener implements MessageListener {
AtomicInteger intx = new AtomicInteger();
private static final Logger LOGGER =
LoggerFactory.getLogger(AddRequestQueueListener.class);
@Override
public void onMessage(Message message) {
LOGGER.info("received testQUeue");
LOGGER.info("received intx"+intx.incrementAndGet());

}

}
When I am invoking sender.sendmessages only once,
I am getting output multiple times.
Below are logs.

2020-03-26 03:43:25,874 INFO  [Thread-2
(ActiveMQ-remoting-threads-ActiveMQServerImpl::serverUUID=ce49a3f9-6ee5-11ea-ae52-340286d42c4f-1943275118)]
org.apache.activemq.artemis.logs.AuditLogger: AMQ601267: User anonymous is
creating a core session on target resource
ActiveMQServerImpl::serverUUID=ce49a3f9-6ee5-11ea-ae52-340286d42c4f [with
parameters: [d932270e-6ee5-11ea-ae52-340286d42c4f, null, , 102400,
RemotingConnectionImpl [ID=d931d8eb-6ee5-11ea-ae52-340286d42c4f,
clientID=null, nodeID=ce49a3f9-6ee5-11ea-ae52-340286d42c4f,
transportConnection=InVMConnection [serverID=0,
id=d931d8eb-6ee5-11ea-ae52-340286d42c4f]], false, false, false, false, null,
org.apache.activemq.artemis.core.protocol.core.impl.CoreSessionCallback@4536128,
true,
org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager$2@65259718,
anonymous]]
2020-03-26 03:43:25,876 INFO  [Thread-2
(ActiveMQ-remoting-threads-ActiveMQServerImpl::serverUUID=ce49a3f9-6ee5-11ea-ae52-340286d42c4f-1943275118)]
org.apache.activemq.artemis.logs.AuditLogger: AMQ601267: User anonymous is
creating a core session on target resource
ActiveMQServerImpl::serverUUID=ce49a3f9-6ee5-11ea-ae52-340286d42c4f [with
parameters: [d932752f-6ee5-11ea-ae52-340286d42c4f, null, , 102400,
RemotingConnectionImpl [ID=d931d8eb-6ee5-11ea-ae52-340286d42c4f,
clientID=null, nodeID=ce49a3f9-6ee5-11ea-ae52-340286d42c4f,
transportConnection=InVMConnection [serverID=0,
id=d931d8eb-6ee5-11ea-ae52-340286d42c4f]], true, true, false, false, null,
org.apache.activemq.artemis.core.protocol.core.impl.CoreSessionCallback@5daca19e,
true,
org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager$2@65259718,
anonymous]]
2020-03-26 03:43:25,909 INFO  [Thread-13
(ActiveMQ-server-org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl$6@165e389b)]
org.apache.activemq.artemis.logs.AuditLogger: AMQ601500: User anonymous is
sending a core message on target resource:
ServerSessionImpl(jms-session=*N/A*) [with parameters: [TransactionImpl
[xid=null, txID=249, xid=null, state=ACTIVE, createTime=1585174405876(Thu
Mar 26 03:43:25 IST 2020), timeoutSeconds=300, nr operations = 0]@32ba055b,
CoreMessage[messageID=0,durable=true,userID=d935f6a0-6ee5-11ea-ae52-340286d42c4f,priority=4,
timestamp=Thu Mar 26 03:43:25 IST 2020,expiration=0, durable=true,
address=testQUeue,size=351,properties=TypedProperties[messageCount=0,__AMQ_CID=d932270d-6ee5-11ea-ae52-340286d42c4f,_AMQ_ROUTING_TYPE=1]]@961604013,
false, false, RoutingContextImpl(Address=null, routingType=null,

Re: ActiveMQ artemis listener not working

2020-03-25 Thread Justin Bertram
I'd like to help, but I really don't understand what you're asking. Can you
elaborate on your use-case and the behavior you're seeing?


Justin

On Wed, Mar 25, 2020 at 11:43 AM rudra1in  wrote:

> HI All,
> I fixed it, there is mismatch in queue name.
> Please help me why fie threads are firing send message?
>
> Thanks in advance,
> RUdra
>
>
>
> --
> Sent from:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
>
>


Re: ActiveMQ artemis listener not working

2020-03-25 Thread rudra1in
HI All,
I fixed it, there is mismatch in queue name.
Please help me why fie threads are firing send message?

Thanks in advance,
RUdra



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html


Re: ActiveMQ artemis listener not working

2020-03-25 Thread rudra1in
Thanks for the response, but this is synchronous and I am looking for
synchronous implementation.

Thanks in advance,
Rudra



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html


Re: ActiveMQ artemis listener not working

2020-03-25 Thread brusdev
Hi,

there is an ActiveMQ Artemis Spring Boot Example at
https://github.com/apache/activemq-artemis/tree/master/examples/features/standard/spring-boot-integration

Regards,
Domenico



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html


ActiveMQ artemis listener not working

2020-03-25 Thread rudra1in
HI All , 
I am not able to receive message.
 
I am using ArtemisMQ with spring boot.
I am using spring boot auto configuration (
https://github.com/spring-projects/spring-boot/tree/master/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis

 
)

Following are properties(application.properties)
spring.artemis.port=61616
spring.artemis.user=svc_enter
spring.artemis.password=svc_enter
spring.artemis.host=localhost
spring.artemis.mode=embedded
spring.artemis.embedded.enabled=true
spring.artemis.embedded.persistent=false
spring.artemis.embedded.queues= synchservice,testQUeue
spring.jms.cache.enabled=false

Below are my codes UserSynchConfiguration.java

  
AddRequestQueueListener.java

  
AddRequestSender.java
  

Below are the messages in console
2020-03-25 18:35:35,050 INFO  [Thread-2
(ActiveMQ-remoting-threads-ActiveMQServerImpl::serverUUID=442ca725-6e99-11ea-9830-340286d42c4f-1537371824)]
org.apache.activemq.artemis.logs.AuditLogger: AMQ601267: User anonymous is
creating a core session on target resource
ActiveMQServerImpl::serverUUID=442ca725-6e99-11ea-9830-340286d42c4f [with
parameters: [50a89b52-6e99-11ea-9830-340286d42c4f, null, , 102400,
RemotingConnectionImpl [ID=50a8261f-6e99-11ea-9830-340286d42c4f,
clientID=null, nodeID=442ca725-6e99-11ea-9830-340286d42c4f,
transportConnection=InVMConnection [serverID=0,
id=50a8261f-6e99-11ea-9830-340286d42c4f]], false, false, false, false, null,
org.apache.activemq.artemis.core.protocol.core.impl.CoreSessionCallback@8855b7f,
true,
org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager$2@4e747756,
anonymous]]
2020-03-25 18:35:35,052 INFO  [Thread-2
(ActiveMQ-remoting-threads-ActiveMQServerImpl::serverUUID=442ca725-6e99-11ea-9830-340286d42c4f-1537371824)]
org.apache.activemq.artemis.logs.AuditLogger: AMQ601267: User anonymous is
creating a core session on target resource
ActiveMQServerImpl::serverUUID=442ca725-6e99-11ea-9830-340286d42c4f [with
parameters: [50a8c263-6e99-11ea-9830-340286d42c4f, null, , 102400,
RemotingConnectionImpl [ID=50a8261f-6e99-11ea-9830-340286d42c4f,
clientID=null, nodeID=442ca725-6e99-11ea-9830-340286d42c4f,
transportConnection=InVMConnection [serverID=0,
id=50a8261f-6e99-11ea-9830-340286d42c4f]], true, true, false, false, null,
org.apache.activemq.artemis.core.protocol.core.impl.CoreSessionCallback@438f089,
true,
org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager$2@4e747756,
anonymous]]
2020-03-25 18:35:35,056 INFO  [Thread-4
(ActiveMQ-server-org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl$6@33d53216)]
org.apache.activemq.artemis.logs.AuditLogger: AMQ601262: User anonymous is
creating address on target resource: 50a8c263-6e99-11ea-9830-340286d42c4f
[with parameters: [testQueue, [ANYCAST], true]]
2020-03-25 18:35:35,057 INFO  [Thread-4
(ActiveMQ-server-org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl$6@33d53216)]
org.apache.activemq.artemis.logs.AuditLogger: AMQ601019: User anonymous is
getting mbean info on target resource:
org.apache.activemq.artemis.core.management.impl.AddressControlImpl@34781d9c
[]
2020-03-25 18:35:35,067 INFO  [Thread-2
(ActiveMQ-server-org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl$6@33d53216)]
org.apache.activemq.artemis.logs.AuditLogger: AMQ601065: User anonymous is
creating a queue on target resource: ServerSessionImpl(jms-session=*N/A*)
[with parameters: [Address [name=testQueue, id=0, routingTypes={ANYCAST},
autoCreated=false, paused=false], testQueue, null, false, true, -1, false,
false, false, -1, null, false, null, false, 0, -1, true, 0, 0, true]]
2020-03-25 18:35:35,069 INFO  [Thread-2
(ActiveMQ-server-org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl$6@33d53216)]
org.apache.activemq.artemis.logs.AuditLogger: AMQ601019: User anonymous is
getting mbean info on target resource:
org.apache.activemq.artemis.core.management.impl.QueueControlImpl@5f83f6c5
[]
2020-03-25 18:35:35,092 INFO  [Thread-7
(ActiveMQ-server-org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl$6@33d53216)]
org.apache.activemq.artemis.logs.AuditLogger: AMQ601500: User anonymous is
sending a core message on target resource:
ServerSessionImpl(jms-session=*N/A*) [with parameters: [TransactionImpl
[xid=null, txID=279, xid=null, state=ACTIVE, createTime=1585141535052(Wed
Mar 25 18:35:35 IST 2020), timeoutSeconds=300, nr operations = 0]@5f6c99d7,
CoreMessage[messageID=0,durable=true,userID=50ae1995-6e99-11ea-9830-340286d42c4f,priority=4,
timestamp=Wed Mar 25 18:35:35