当前位置: 首页>>代码示例>>Java>>正文


Java Session.open方法代码示例

本文整理汇总了Java中org.apache.qpid.proton.engine.Session.open方法的典型用法代码示例。如果您正苦于以下问题:Java Session.open方法的具体用法?Java Session.open怎么用?Java Session.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.qpid.proton.engine.Session的用法示例。


在下文中一共展示了Session.open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolve

import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
private <T extends Link> T resolve(String remote, String local,
                                   LinkResolver<T> resolver,
                                   LinkConstructor<T> constructor) {
    String host = remote.substring(2).split("/", 2)[0];
    T link = resolver.resolve(remote);
    if (link == null) {
        Connection conn = connections.get(host);
        if (conn == null) {
            conn = Connection.Factory.create();
            conn.collect(collector);
            conn.setHostname(host);
            conn.open();
            connections.put(host, conn);
        }

        Session ssn = conn.session();
        ssn.open();

        link = constructor.create(ssn, remote, local);
        link.open();
    }
    return link;
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:24,代码来源:Pool.java

示例2: onConnectionInit

import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
@Override
public void onConnectionInit(Event event) {
    Connection conn = event.getConnection();

    // Every session or link could have their own handler(s) if we
    // wanted simply by adding the handler to the given session
    // or link
    Session ssn = conn.session();

    // If a link doesn't have an event handler, the events go to
    // its parent session. If the session doesn't have a handler
    // the events go to its parent connection. If the connection
    // doesn't have a handler, the events go to the reactor.
    Sender snd = ssn.sender("sender");
    conn.open();
    ssn.open();
    snd.open();
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:19,代码来源:Send.java

示例3: testOpenSessionBeforeOpenConnection

import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
@Test
public void testOpenSessionBeforeOpenConnection()
{
    MockTransportImpl transport = new MockTransportImpl();
    Connection connection = Proton.connection();
    transport.bind(connection);

    Session session = connection.session();
    session.open();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 0, transport.writes.size());

    connection.open();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:24,代码来源:TransportImplTest.java

示例4: onSessionRemoteOpen

import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
@Override
public void onSessionRemoteOpen(Event evt) {
    Session ssn = evt.getSession();
    if (ssn.getLocalState() == EndpointState.UNINITIALIZED) {
        ssn.open();
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:8,代码来源:Handshaker.java

示例5: doOpenLinkBeforeOpenConnectionTestImpl

import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
void doOpenLinkBeforeOpenConnectionTestImpl(boolean receiverLink)
{
    MockTransportImpl transport = new MockTransportImpl();
    Connection connection = Proton.connection();
    transport.bind(connection);

    Session session = connection.session();
    session.open();

    Link link = null;
    if(receiverLink)
    {
        link = session.receiver("myReceiver");
    }
    else
    {
        link = session.sender("mySender");
    }
    link.open();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 0, transport.writes.size());

    // Now open the connection, expect the Open, Begin, and Attach frames
    connection.open();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
    assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:36,代码来源:TransportImplTest.java

示例6: testReceiverFlowBeforeOpenConnection

import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
@Test
public void testReceiverFlowBeforeOpenConnection()
{
    MockTransportImpl transport = new MockTransportImpl();
    Connection connection = Proton.connection();
    transport.bind(connection);

    Session session = connection.session();
    session.open();

    Receiver reciever = session.receiver("myReceiver");
    reciever.flow(5);

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 0, transport.writes.size());

    // Now open the connection, expect the Open and Begin frames but
    // nothing else as we haven't opened the receiver itself yet.
    connection.open();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:29,代码来源:TransportImplTest.java

示例7: testSessionBeginAfterCloseSent

import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
/**
 * Verify that no Begin frame is emitted by the Transport should a Session open
 * after the Close frame was sent.
 */
@Test
public void testSessionBeginAfterCloseSent()
{
    MockTransportImpl transport = new MockTransportImpl();
    Connection connection = Proton.connection();
    transport.bind(connection);

    connection.open();

    Session session = connection.session();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 1, transport.writes.size());

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);

    // Send the necessary response to Open
    transport.handleFrame(new TransportFrame(0, new Open(), null));

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 1, transport.writes.size());

    // Cause a Close frame to be sent
    connection.close();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Close);

    // Open the session and verify the transport doesn't
    // send any Begin frame, as a Close frame was sent already.
    session.open();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:41,代码来源:TransportImplTest.java

示例8: assertConnectionIsUsable

import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
private void assertConnectionIsUsable()
{
    Session clientSesion = _clientConnection.session();
    clientSesion.open();
    _pumper.pumpAll();

    Session serverSession = _serverConnection.sessionHead(of(UNINITIALIZED), of(ACTIVE));
    serverSession.open();
    _pumper.pumpAll();

    assertEnpointState(clientSesion, ACTIVE, ACTIVE);
    assertEnpointState(serverSession, ACTIVE, ACTIVE);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:14,代码来源:ConnectionTest.java

示例9: onConnectionInit

import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
@Override
public void onConnectionInit(Event event) {
    Connection conn = event.getConnection();
    Session ssn = conn.session();
    Sender snd = ssn.sender("sender");
    conn.open();
    ssn.open();
    snd.open();
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:10,代码来源:ReactorTest.java

示例10: onRemoteOpen

import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
@Override
public void onRemoteOpen(Session session) throws Exception {
   getSessionExtension(session).initialise();
   lock();
   try {
      session.open();
   } finally {
      unlock();
   }
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:11,代码来源:AMQPConnectionContext.java

示例11: doOpenLinkBeforeOpenSessionTestImpl

import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
void doOpenLinkBeforeOpenSessionTestImpl(boolean receiverLink)
{
    MockTransportImpl transport = new MockTransportImpl();
    Connection connection = Proton.connection();
    transport.bind(connection);

    // Open the connection
    connection.open();

    // Create but don't open the session
    Session session = connection.session();

    // Open the link
    Link link = null;
    if(receiverLink)
    {
        link = session.receiver("myReceiver");
    }
    else
    {
        link = session.sender("mySender");
    }
    link.open();

    pumpMockTransport(transport);

    // Expect only an Open frame, no attach should be sent as the session isn't open
    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 1, transport.writes.size());
    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);

    // Now open the session, expect the Begin
    session.open();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());
    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
    // Note: an Attach wasn't sent because link is no longer 'modified' after earlier pump. It
    // could easily be argued it should, given how the engine generally handles things. Seems
    // unlikely to be of much real world concern.
    //assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:44,代码来源:TransportImplTest.java

示例12: doLinkAttachAfterEndSentTestImpl

import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
void doLinkAttachAfterEndSentTestImpl(boolean receiverLink)
{
    MockTransportImpl transport = new MockTransportImpl();
    Connection connection = Proton.connection();
    transport.bind(connection);

    connection.open();

    Session session = connection.session();
    session.open();

    Link link = null;
    if(receiverLink)
    {
        link = session.receiver("myReceiver");
    }
    else
    {
        link = session.sender("mySender");
    }

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);

    // Send the necessary responses to open/begin
    transport.handleFrame(new TransportFrame(0, new Open(), null));

    Begin begin = new Begin();
    begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
    transport.handleFrame(new TransportFrame(0, begin, null));

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());

    // Cause a End frame to be sent
    session.close();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
    assertTrue("Unexpected frame type", transport.writes.get(2) instanceof End);

    // Open the link and verify the transport doesn't
    // send any Attach frame, as an End frame was sent already.
    link.open();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:52,代码来源:TransportImplTest.java

示例13: doLinkDetachAfterEndSentTestImpl

import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
void doLinkDetachAfterEndSentTestImpl(boolean receiverLink)
{
    MockTransportImpl transport = new MockTransportImpl();
    Connection connection = Proton.connection();
    transport.bind(connection);

    connection.open();

    Session session = connection.session();
    session.open();

    Link link = null;
    if(receiverLink)
    {
        link = session.receiver("myReceiver");
    }
    else
    {
        link = session.sender("mySender");
    }
    link.open();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
    assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);

    // Send the necessary responses to open/begin
    transport.handleFrame(new TransportFrame(0, new Open(), null));

    Begin begin = new Begin();
    begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
    transport.handleFrame(new TransportFrame(0, begin, null));

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());

    // Cause an End frame to be sent
    session.close();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
    assertTrue("Unexpected frame type", transport.writes.get(3) instanceof End);

    // Close the link and verify the transport doesn't
    // send any Detach frame, as an End frame was sent already.
    link.close();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:54,代码来源:TransportImplTest.java

示例14: testSenderSendBeforeOpenConnection

import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
@Test
public void testSenderSendBeforeOpenConnection()
{
    MockTransportImpl transport = new MockTransportImpl();

    Connection connection = Proton.connection();
    transport.bind(connection);

    Collector collector = Collector.Factory.create();
    connection.collect(collector);

    Session session = connection.session();
    session.open();

    String linkName = "mySender";
    Sender sender = session.sender(linkName);
    sender.open();

    sendMessage(sender, "tag1", "content1");

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 0, transport.writes.size());

    // Now open the connection, expect the Open and Begin and Attach frames but
    // nothing else as we the sender wont have credit yet.
    connection.open();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);
    assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Attach);

    // Send the necessary responses to open/begin/attach then give sender credit
    transport.handleFrame(new TransportFrame(0, new Open(), null));

    Begin begin = new Begin();
    begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
    transport.handleFrame(new TransportFrame(0, begin, null));

    Attach attach = new Attach();
    attach.setHandle(UnsignedInteger.ZERO);
    attach.setRole(Role.RECEIVER);
    attach.setName(linkName);
    attach.setInitialDeliveryCount(UnsignedInteger.ZERO);
    transport.handleFrame(new TransportFrame(0, attach, null));

    Flow flow = new Flow();
    flow.setHandle(UnsignedInteger.ZERO);
    flow.setDeliveryCount(UnsignedInteger.ZERO);
    flow.setNextIncomingId(UnsignedInteger.ONE);
    flow.setNextOutgoingId(UnsignedInteger.ZERO);
    flow.setIncomingWindow(UnsignedInteger.valueOf(1024));
    flow.setOutgoingWindow(UnsignedInteger.valueOf(1024));
    flow.setLinkCredit(UnsignedInteger.valueOf(10));

    transport.handleFrame(new TransportFrame(0, flow, null));

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());

    // Now pump the transport again and expect a transfer for the message
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 4, transport.writes.size());
    assertTrue("Unexpected frame type", transport.writes.get(3) instanceof Transfer);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:70,代码来源:TransportImplTest.java

示例15: testSessionEndAfterCloseSent

import org.apache.qpid.proton.engine.Session; //导入方法依赖的package包/类
/**
 * Verify that no End frame is emitted by the Transport should a Session close
 * after the Close frame was sent.
 */
@Test
public void testSessionEndAfterCloseSent()
{
    MockTransportImpl transport = new MockTransportImpl();
    Connection connection = Proton.connection();
    transport.bind(connection);

    connection.open();

    Session session = connection.session();
    session.open();

    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());

    assertTrue("Unexpected frame type", transport.writes.get(0) instanceof Open);
    assertTrue("Unexpected frame type", transport.writes.get(1) instanceof Begin);

    // Send the necessary responses to open/begin
    transport.handleFrame(new TransportFrame(0, new Open(), null));

    Begin begin = new Begin();
    begin.setRemoteChannel(UnsignedShort.valueOf((short) 0));
    transport.handleFrame(new TransportFrame(0, begin, null));

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 2, transport.writes.size());

    // Cause a Close frame to be sent
    connection.close();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
    assertTrue("Unexpected frame type", transport.writes.get(2) instanceof Close);

    // Close the session and verify the transport doesn't
    // send any End frame, as a Close frame was sent already.
    session.close();
    pumpMockTransport(transport);

    assertEquals("Unexpected frames written: " + getFrameTypesWritten(transport), 3, transport.writes.size());
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:47,代码来源:TransportImplTest.java


注:本文中的org.apache.qpid.proton.engine.Session.open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。