Search in sources :

Example 11 with CreateSessionRequest

use of com.swiftmq.jms.smqp.v400.CreateSessionRequest in project swiftmq-client by iitsoftware.

the class TopicConnectionImpl method createTopicSession.

public TopicSession createTopicSession(boolean transacted, int acknowledgeMode) throws JMSException {
    verifyState();
    SessionImpl topicSession = null;
    CreateSessionReply reply = null;
    try {
        reply = (CreateSessionReply) requestRegistry.request(new CreateSessionRequest(0, transacted, acknowledgeMode, CreateSessionRequest.TOPIC_SESSION));
    } catch (Exception e) {
        throw ExceptionConverter.convert(e);
    }
    if (reply.isOk()) {
        int dispatchId = reply.getSessionDispatchId();
        String cid = clientID != null ? clientID : internalCID;
        topicSession = new SessionImpl(SessionImpl.TYPE_TOPIC_SESSION, this, transacted, acknowledgeMode, dispatchId, requestRegistry, myHostname, cid);
        topicSession.setUserName(userName);
        topicSession.setMyDispatchId(addRequestService(topicSession));
        addSession(topicSession);
    } else {
        throw ExceptionConverter.convert(reply.getException());
    }
    return (topicSession);
}
Also used : CreateSessionRequest(com.swiftmq.jms.smqp.v510.CreateSessionRequest) CreateSessionReply(com.swiftmq.jms.smqp.v510.CreateSessionReply) JMSException(javax.jms.JMSException)

Example 12 with CreateSessionRequest

use of com.swiftmq.jms.smqp.v400.CreateSessionRequest in project java-spanner by googleapis.

the class GapicSpannerRpc method createSession.

@Override
public Session createSession(String databaseName, @Nullable Map<String, String> labels, @Nullable Map<Option, ?> options) throws SpannerException {
    CreateSessionRequest.Builder requestBuilder = CreateSessionRequest.newBuilder().setDatabase(databaseName);
    if (labels != null && !labels.isEmpty()) {
        Session.Builder session = Session.newBuilder().putAllLabels(labels);
        requestBuilder.setSession(session);
    }
    CreateSessionRequest request = requestBuilder.build();
    GrpcCallContext context = newCallContext(options, databaseName, request, SpannerGrpc.getCreateSessionMethod());
    return get(spannerStub.createSessionCallable().futureCall(request, context));
}
Also used : CreateSessionRequest(com.google.spanner.v1.CreateSessionRequest) GrpcCallContext(com.google.api.gax.grpc.GrpcCallContext) Session(com.google.spanner.v1.Session)

Example 13 with CreateSessionRequest

use of com.swiftmq.jms.smqp.v400.CreateSessionRequest in project grpc-gcp-java by GoogleCloudPlatform.

the class SpannerIntegrationTest method testCreateAndGetSessionBlocking.

@Test
public void testCreateAndGetSessionBlocking() throws Exception {
    SpannerBlockingStub stub = getSpannerBlockingStub();
    CreateSessionRequest req = CreateSessionRequest.newBuilder().setDatabase(DATABASE_PATH).build();
    // The first MAX_CHANNEL requests (without affinity) should be distributed 1 per channel.
    List<Session> sessions = new ArrayList<>();
    for (int i = 0; i < MAX_CHANNEL; i++) {
        Session session = stub.createSession(req);
        assertThat(session).isNotEqualTo(null);
        sessions.add(session);
        Session responseGet = stub.getSession(GetSessionRequest.newBuilder().setName(session.getName()).build());
        assertEquals(responseGet.getName(), session.getName());
    }
    checkChannelRefs(MAX_CHANNEL, 0, 1);
    for (Session session : sessions) {
        deleteSession(stub, session);
    }
    checkChannelRefs(MAX_CHANNEL, 0, 0);
}
Also used : CreateSessionRequest(com.google.spanner.v1.CreateSessionRequest) SpannerBlockingStub(com.google.spanner.v1.SpannerGrpc.SpannerBlockingStub) ArrayList(java.util.ArrayList) Session(com.google.spanner.v1.Session) Test(org.junit.Test)

Example 14 with CreateSessionRequest

use of com.swiftmq.jms.smqp.v400.CreateSessionRequest in project grpc-gcp-java by GoogleCloudPlatform.

the class SpannerIntegrationTest method testBoundAfterUnbind.

@Test
public void testBoundAfterUnbind() {
    SpannerBlockingStub stub = getSpannerBlockingStub();
    CreateSessionRequest req = CreateSessionRequest.newBuilder().setDatabase(DATABASE_PATH).build();
    Session session = stub.createSession(req);
    stub.deleteSession(DeleteSessionRequest.newBuilder().setName(session.getName()).build());
    expectedEx.expect(StatusRuntimeException.class);
    expectedEx.expectMessage("NOT_FOUND: Session not found: " + session.getName());
    stub.getSession(GetSessionRequest.newBuilder().setName(session.getName()).build());
}
Also used : CreateSessionRequest(com.google.spanner.v1.CreateSessionRequest) SpannerBlockingStub(com.google.spanner.v1.SpannerGrpc.SpannerBlockingStub) Session(com.google.spanner.v1.Session) Test(org.junit.Test)

Example 15 with CreateSessionRequest

use of com.swiftmq.jms.smqp.v400.CreateSessionRequest in project grpc-gcp-java by GoogleCloudPlatform.

the class SpannerLoadTest method createFutureSessions.

private static List<String> createFutureSessions(SpannerFutureStub stub) throws ExecutionException, InterruptedException {
    List<ListenableFuture<Session>> futures = new ArrayList<>();
    List<String> futureNames = new ArrayList<>();
    // Check CreateSession with multiple channels and streams,
    CreateSessionRequest req = CreateSessionRequest.newBuilder().setDatabase(DATABASE).build();
    for (int i = 0; i < MAX_CHANNEL * MAX_STREAM / 2; i++) {
        ListenableFuture<Session> future = stub.createSession(req);
        futures.add(future);
    }
    for (ListenableFuture<Session> future : futures) {
        futureNames.add(future.get().getName());
    }
    return futureNames;
}
Also used : CreateSessionRequest(com.google.spanner.v1.CreateSessionRequest) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Session(com.google.spanner.v1.Session)

Aggregations

CreateSessionRequest (com.google.spanner.v1.CreateSessionRequest)11 Session (com.google.spanner.v1.Session)11 JMSException (javax.jms.JMSException)7 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 SpannerBlockingStub (com.google.spanner.v1.SpannerGrpc.SpannerBlockingStub)4 IllegalStateException (javax.jms.IllegalStateException)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 CreateSessionReply (com.swiftmq.jms.smqp.v600.CreateSessionReply)2 CreateSessionRequest (com.swiftmq.jms.smqp.v600.CreateSessionRequest)2 CreateSessionReply (com.swiftmq.jms.smqp.v610.CreateSessionReply)2 CreateSessionRequest (com.swiftmq.jms.smqp.v610.CreateSessionRequest)2 CreateSessionReply (com.swiftmq.jms.smqp.v630.CreateSessionReply)2 CreateSessionRequest (com.swiftmq.jms.smqp.v630.CreateSessionRequest)2 CreateSessionReply (com.swiftmq.jms.smqp.v750.CreateSessionReply)2 CreateSessionRequest (com.swiftmq.jms.smqp.v750.CreateSessionRequest)2 HashMap (java.util.HashMap)2 GrpcCallContext (com.google.api.gax.grpc.GrpcCallContext)1 ByteString (com.google.protobuf.ByteString)1