[Qpid Java Broker] Get SessionPrincipal

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Qpid Java Broker] Get SessionPrincipal

Vavricka
Hi,

  I would like to get current session in Java Broker source code. In class ProducerFlowControlOverflowPolicyHandler in checkOverfull() method there is current session get by

Set<SessionPrincipal> sessionPrincipals = subject.getPrincipals(SessionPrincipal.class);

When I use this for AMQP 1.0 connection, everything goes fine and I get session. But when I use AMQP 0-10 client for connection to broker, SessionPrincipal is empty.

I checked that in constructor of AbstractAMQPSession session added to Subject. But when I get Subject in OverflowPolicyHandler, there is no SessionPrincipal.

Simplified code how I get current session below:

                    Subject subject = Subject.getSubject(AccessController.getContext());
                    Set<SessionPrincipal> sessionPrincipals = subject.getPrincipals(SessionPrincipal.class);
                    SessionPrincipal sessionPrincipal = sessionPrincipals.iterator().next();
                    AMQPSession<?, ?> session = sessionPrincipal.getSession();

Am I doing anything wrong?

Vavricka
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Qpid Java Broker] Get SessionPrincipal

Keith Wall
Hi Vavricka,

The absence of the SessionPrincipal would suggest the calling thread
is somehow running without the Session's _accessControllerContext
which would suggest a bug.

The AMQP connection implementations organise for connection work to be
done with the AbstractAMQPConnection#_accessControllerContext  and
session work is done additionally with
AbstractAMQPSession#_accessControllerContext.  In 0-10 case, the
pertinent code is AMQPConnection_0_10Impl#received and
ServerAssembler#received(java.util.List<org.apache.qpid.server.protocol.v0_10.ServerFrame>).

Do you have a stack trace generated within the checkOverfull method,
including the thread name, and a reproducing test case you can share?

Kind regards, Keith Wall.

On 2 June 2017 at 11:04, Vavricka <[hidden email]> wrote:

> Hi,
>
>   I would like to get current session in Java Broker source code. In class
> ProducerFlowControlOverflowPolicyHandler in checkOverfull() method there is
> current session get by
>
> Set<SessionPrincipal> sessionPrincipals =
> subject.getPrincipals(SessionPrincipal.class);
>
> When I use this for AMQP 1.0 connection, everything goes fine and I get
> session. But when I use AMQP 0-10 client for connection to broker,
> SessionPrincipal is empty.
>
> I checked that in constructor of AbstractAMQPSession session added to
> Subject. But when I get Subject in OverflowPolicyHandler, there is no
> SessionPrincipal.
>
> Simplified code how I get current session below:
>
>                     Subject subject =
> Subject.getSubject(AccessController.getContext());
>                     Set<SessionPrincipal> sessionPrincipals =
> subject.getPrincipals(SessionPrincipal.class);
>                     SessionPrincipal sessionPrincipal =
> sessionPrincipals.iterator().next();
>                     AMQPSession<?, ?> session =
> sessionPrincipal.getSession();
>
> Am I doing anything wrong?
>
> Vavricka
>
>
>
> --
> View this message in context: http://qpid.2158936.n2.nabble.com/Qpid-Java-Broker-Get-SessionPrincipal-tp7663741.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Qpid Java Broker] Get SessionPrincipal

Vavricka
Complete stacktrace in attached file threads_report.txt

Stacktrace within checkOverfull method:

"IO-/127.0.0.1:57308@5531" prio=5 tid=0x21 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
          at org.apache.qpid.server.queue.ProducerFlowControlOverflowPolicyHandler$Handler.checkOverfull(ProducerFlowControlOverflowPolicyHandler.java:177)
          at org.apache.qpid.server.queue.ProducerFlowControlOverflowPolicyHandler$Handler.checkOverflow(ProducerFlowControlOverflowPolicyHandler.java:88)
          at org.apache.qpid.server.queue.ProducerFlowControlOverflowPolicyHandler.checkOverflow(ProducerFlowControlOverflowPolicyHandler.java:57)
          at org.apache.qpid.server.queue.AbstractQueue.doEnqueue(AbstractQueue.java:1167)
          at org.apache.qpid.server.queue.AbstractQueue.enqueue(AbstractQueue.java:1096)
          at org.apache.qpid.server.message.RoutingResult$1.postCommit(RoutingResult.java:136)
          at org.apache.qpid.server.txn.AsyncAutoCommitTransaction$3.postCommit(AsyncAutoCommitTransaction.java:304)
          at org.apache.qpid.server.protocol.v0_10.ServerSession$AsyncCommand.complete(ServerSession.java:1716)
          at org.apache.qpid.server.protocol.v0_10.ServerSession.awaitCommandCompletion(ServerSession.java:1651)
          at org.apache.qpid.server.protocol.v0_10.ServerSession.receivedComplete(ServerSession.java:1615)
          at org.apache.qpid.server.protocol.v0_10.ServerConnection.receivedComplete(ServerConnection.java:422)
          at org.apache.qpid.server.protocol.v0_10.AMQPConnection_0_10Impl.lambda$received$1(AMQPConnection_0_10Impl.java:145)
          at org.apache.qpid.server.protocol.v0_10.AMQPConnection_0_10Impl$$Lambda$24.869704345.run(Unknown Source:-1)
          at java.security.AccessController.doPrivileged(AccessController.java:-1)
          at org.apache.qpid.server.protocol.v0_10.AMQPConnection_0_10Impl.received(AMQPConnection_0_10Impl.java:139)
          at org.apache.qpid.server.transport.MultiVersionProtocolEngine.received(MultiVersionProtocolEngine.java:130)
          at org.apache.qpid.server.transport.NonBlockingConnection.processAmqpData(NonBlockingConnection.java:593)
          at org.apache.qpid.server.transport.NonBlockingConnectionPlainDelegate.processData(NonBlockingConnectionPlainDelegate.java:58)
          at org.apache.qpid.server.transport.NonBlockingConnection.doRead(NonBlockingConnection.java:483)
          at org.apache.qpid.server.transport.NonBlockingConnection.doWork(NonBlockingConnection.java:270)
          at org.apache.qpid.server.transport.NetworkConnectionScheduler.processConnection(NetworkConnectionScheduler.java:157)
          at org.apache.qpid.server.transport.SelectorThread$ConnectionProcessor.processConnection(SelectorThread.java:563)
          at org.apache.qpid.server.transport.SelectorThread$SelectionTask.performSelect(SelectorThread.java:354)
          at org.apache.qpid.server.transport.SelectorThread$SelectionTask.run(SelectorThread.java:97)
          at org.apache.qpid.server.transport.SelectorThread.run(SelectorThread.java:521)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          at java.lang.Thread.run(Thread.java:748)

Test case:

1] Create queue 'test.queue'
2] Set queue parameters Maximum Queue Depth (Messages) and Maximum Queue Depth (Bytes) to 1
3] Send message with AMQP 0-10 client to 'test.queue'
4] sessionPrincipals variable is empty in checkOverfull method

I use latest version of Java Broker from git.
AMQP 0-10 client uses libraries 'qpid-client version 6.1.1'.

Sending message in client below:

Connection connection = ((ConnectionFactory) context.lookup("connection")).createConnection();
Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
producer = session.createProducer((Destination) context.lookup("queue"));
connection.start();
TextMessage message = session.createTextMessage("test message");
producer.send(message, DeliveryMode.PERSISTENT, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
producer.close();
session.close();
connection.close();
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Qpid Java Broker] Get SessionPrincipal

Oleksandr Rudyy
Vavricka,

Thanks for reporting the issue and providing instruction how to reproduce
it. I raised JIRA QPID-7808 [1] for it.
I am going to fix the defect.

Kind Regards,
Alex

[1] https://issues.apache.org/jira/browse/QPID-7808

On 2 June 2017 at 13:13, Vavricka <[hidden email]> wrote:

> Complete stacktrace in attached file  threads_report.txt
> <http://qpid.2158936.n2.nabble.com/file/n7663743/threads_report.txt>
>
> Stacktrace within checkOverfull method:
>
> "IO-/127.0.0.1:57308@5531" prio=5 tid=0x21 nid=NA runnable
>   java.lang.Thread.State: RUNNABLE
>           at
> org.apache.qpid.server.queue.ProducerFlowControlOverflowPol
> icyHandler$Handler.checkOverfull(ProducerFlowControlOverflowPol
> icyHandler.java:177)
>           at
> org.apache.qpid.server.queue.ProducerFlowControlOverflowPol
> icyHandler$Handler.checkOverflow(ProducerFlowControlOverflowPol
> icyHandler.java:88)
>           at
> org.apache.qpid.server.queue.ProducerFlowControlOverflowPol
> icyHandler.checkOverflow(ProducerFlowControlOverflowPolicyHandler.java:57)
>           at
> org.apache.qpid.server.queue.AbstractQueue.doEnqueue(
> AbstractQueue.java:1167)
>           at
> org.apache.qpid.server.queue.AbstractQueue.enqueue(
> AbstractQueue.java:1096)
>           at
> org.apache.qpid.server.message.RoutingResult$1.
> postCommit(RoutingResult.java:136)
>           at
> org.apache.qpid.server.txn.AsyncAutoCommitTransaction$3.postCommit(
> AsyncAutoCommitTransaction.java:304)
>           at
> org.apache.qpid.server.protocol.v0_10.ServerSession$AsyncCommand.complete(
> ServerSession.java:1716)
>           at
> org.apache.qpid.server.protocol.v0_10.ServerSession.
> awaitCommandCompletion(ServerSession.java:1651)
>           at
> org.apache.qpid.server.protocol.v0_10.ServerSession.receivedComplete(
> ServerSession.java:1615)
>           at
> org.apache.qpid.server.protocol.v0_10.ServerConnection.receivedComplete(
> ServerConnection.java:422)
>           at
> org.apache.qpid.server.protocol.v0_10.AMQPConnection_
> 0_10Impl.lambda$received$1(AMQPConnection_0_10Impl.java:145)
>           at
> org.apache.qpid.server.protocol.v0_10.AMQPConnection_
> 0_10Impl$$Lambda$24.869704345.run(Unknown
> Source:-1)
>           at java.security.AccessController.doPrivileged(
> AccessController.java:-1)
>           at
> org.apache.qpid.server.protocol.v0_10.AMQPConnection_0_10Impl.received(
> AMQPConnection_0_10Impl.java:139)
>           at
> org.apache.qpid.server.transport.MultiVersionProtocolEngine.received(
> MultiVersionProtocolEngine.java:130)
>           at
> org.apache.qpid.server.transport.NonBlockingConnection.processAmqpData(
> NonBlockingConnection.java:593)
>           at
> org.apache.qpid.server.transport.NonBlockingConnectionPlainDele
> gate.processData(NonBlockingConnectionPlainDelegate.java:58)
>           at
> org.apache.qpid.server.transport.NonBlockingConnection.doRead(
> NonBlockingConnection.java:483)
>           at
> org.apache.qpid.server.transport.NonBlockingConnection.doWork(
> NonBlockingConnection.java:270)
>           at
> org.apache.qpid.server.transport.NetworkConnectionScheduler.
> processConnection(NetworkConnectionScheduler.java:157)
>           at
> org.apache.qpid.server.transport.SelectorThread$ConnectionProcessor.
> processConnection(SelectorThread.java:563)
>           at
> org.apache.qpid.server.transport.SelectorThread$
> SelectionTask.performSelect(SelectorThread.java:354)
>           at
> org.apache.qpid.server.transport.SelectorThread$SelectionTask.run(
> SelectorThread.java:97)
>           at
> org.apache.qpid.server.transport.SelectorThread.run(
> SelectorThread.java:521)
>           at
> java.util.concurrent.ThreadPoolExecutor.runWorker(
> ThreadPoolExecutor.java:1142)
>           at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(
> ThreadPoolExecutor.java:617)
>           at java.lang.Thread.run(Thread.java:748)
>
> Test case:
>
> 1] Create queue 'test.queue'
> 2] Set queue parameters Maximum Queue Depth (Messages) and Maximum Queue
> Depth (Bytes) to 1
> 3] Send message with AMQP 0-10 client to 'test.queue'
> 4] sessionPrincipals variable is empty in checkOverfull method
>
> I use latest version of Java Broker from git.
> AMQP 0-10 client uses libraries 'qpid-client version 6.1.1'.
>
> Sending message in client below:
>
> Connection connection = ((ConnectionFactory)
> context.lookup("connection")).createConnection();
> Session session = connection.createSession(false,
> Session.CLIENT_ACKNOWLEDGE);
> producer = session.createProducer((Destination) context.lookup("queue"));
> connection.start();
> TextMessage message = session.createTextMessage("test message");
> producer.send(message, DeliveryMode.PERSISTENT, Message.DEFAULT_PRIORITY,
> Message.DEFAULT_TIME_TO_LIVE);
> producer.close();
> session.close();
> connection.close();
>
>
>
> --
> View this message in context: http://qpid.2158936.n2.nabble.
> com/Qpid-Java-Broker-Get-SessionPrincipal-tp7663741p7663743.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Qpid Java Broker] Get SessionPrincipal

Vavricka
Thanks for quick answer and raising JIRA.

Regards,
Vavricka
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Qpid Java Broker] Get SessionPrincipal

Oleksandr Rudyy
Vavricka,
I made a change which should fix the issue.

Alex

On 2 June 2017 at 14:35, Vavricka <[hidden email]> wrote:

> Thanks for quick answer and raising JIRA.
>
> Regards,
> Vavricka
>
>
>
> --
> View this message in context: http://qpid.2158936.n2.nabble.
> com/Qpid-Java-Broker-Get-SessionPrincipal-tp7663741p7663746.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Qpid Java Broker] Get SessionPrincipal

Vavricka
Thanks,

  it works like a charm.

 Vavricka
Loading...