org.apache.rocketmq.remoting.protocol.LanguageCode Java Examples

The following examples show how to use org.apache.rocketmq.remoting.protocol.LanguageCode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdminBrokerProcessor.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public RemotingCommand resetOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final ResetOffsetRequestHeader requestHeader =
        (ResetOffsetRequestHeader)request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
    log.info("[reset-offset] reset offset started by {}. topic={}, group={}, timestamp={}, isForce={}",
        RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup(),
        requestHeader.getTimestamp(), requestHeader.isForce());
    boolean isC = false;
    LanguageCode language = request.getLanguage();
    switch (language) {
        case CPP:
            isC = true;
            break;
    }
    return this.brokerController.getBroker2Client().resetOffset(requestHeader.getTopic(), requestHeader.getGroup(),
        requestHeader.getTimestamp(), requestHeader.isForce(), isC);
}
 
Example #2
Source File: AdminBrokerProcessor.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public RemotingCommand resetOffset(ChannelHandlerContext ctx,
    RemotingCommand request) throws RemotingCommandException {
    final ResetOffsetRequestHeader requestHeader =
        (ResetOffsetRequestHeader) request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
    log.info("[reset-offset] reset offset started by {}. topic={}, group={}, timestamp={}, isForce={}",
        RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup(),
        requestHeader.getTimestamp(), requestHeader.isForce());
    boolean isC = false;
    LanguageCode language = request.getLanguage();
    switch (language) {
        case CPP:
            isC = true;
            break;
    }
    return this.brokerController.getBroker2Client().resetOffset(requestHeader.getTopic(), requestHeader.getGroup(),
        requestHeader.getTimestamp(), requestHeader.isForce(), isC);
}
 
Example #3
Source File: QueryMsgByUniqueKeySubCommandTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testExecuteConsumePassively() throws SubCommandException, InterruptedException, MQBrokerException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException {

    ConsumerConnection consumerConnection = new ConsumerConnection();
    consumerConnection.setConsumeType(ConsumeType.CONSUME_PASSIVELY);
    HashSet<Connection> connectionSet = new HashSet<>();
    Connection conn = new Connection();
    conn.setClientId("clientIdTestStr");
    conn.setClientAddr("clientAddrTestStr");
    conn.setLanguage(LanguageCode.JAVA);
    conn.setVersion(2);
    connectionSet.add(conn);
    consumerConnection.setConnectionSet(connectionSet);
    when(mQClientAPIImpl.getConsumerConnectionList(anyString(), anyString(), anyLong())).thenReturn(consumerConnection);

    Options options = ServerUtil.buildCommandlineOptions(new Options());

    String[] args = new String[]{"-t myTopicTest", "-i 7F000001000004D20000000000000066"};
    CommandLine commandLine = ServerUtil.parseCmdLine("mqadmin ", args, cmd.buildCommandlineOptions(options), new PosixParser());
    cmd.execute(commandLine, options, null);



}
 
Example #4
Source File: ClientManageProcessorTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@Before
public void init() {
    when(handlerContext.channel()).thenReturn(channel);
    clientManageProcessor = new ClientManageProcessor(brokerController);
    clientChannelInfo = new ClientChannelInfo(channel, clientId, LanguageCode.JAVA, 100);
    brokerController.getProducerManager().registerProducer(group, clientChannelInfo);

    ConsumerData consumerData = createConsumerData(group, topic);
    brokerController.getConsumerManager().registerConsumer(
        consumerData.getGroupName(),
        clientChannelInfo,
        consumerData.getConsumeType(),
        consumerData.getMessageModel(),
        consumerData.getConsumeFromWhere(),
        consumerData.getSubscriptionDataSet(),
        false);
}
 
Example #5
Source File: AbstractOMSProducer.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
AbstractOMSProducer(final KeyValue properties) {
    this.properties = properties;
    this.rocketmqProducer = new DefaultMQProducer();
    this.clientConfig = BeanUtils.populate(properties, ClientConfig.class);

    if ("true".equalsIgnoreCase(System.getenv("OMS_RMQ_DIRECT_NAME_SRV"))) {
        String accessPoints = clientConfig.getAccessPoints();
        if (accessPoints == null || accessPoints.isEmpty()) {
            throw new OMSRuntimeException("-1", "OMS AccessPoints is null or empty.");
        }

        this.rocketmqProducer.setNamesrvAddr(accessPoints.replace(',', ';'));
    }

    this.rocketmqProducer.setProducerGroup(clientConfig.getRmqProducerGroup());

    String producerId = buildInstanceName();
    this.rocketmqProducer.setSendMsgTimeout(clientConfig.getOperationTimeout());
    this.rocketmqProducer.setInstanceName(producerId);
    this.rocketmqProducer.setMaxMessageSize(1024 * 1024 * 4);
    this.rocketmqProducer.setLanguage(LanguageCode.OMS);
    properties.put(OMSBuiltinKeys.PRODUCER_ID, producerId);
}
 
Example #6
Source File: RemotingServerTest.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
@Test
public void testInvokeAsync() throws InterruptedException, RemotingConnectException,
    RemotingTimeoutException, RemotingTooMuchRequestException, RemotingSendRequestException {

    final CountDownLatch latch = new CountDownLatch(1);
    RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
    request.setRemark("messi");
    remotingClient.invokeAsync("localhost:8888", request, 1000 * 3, new InvokeCallback() {
        @Override
        public void operationComplete(ResponseFuture responseFuture) {
            latch.countDown();
            assertTrue(responseFuture != null);
            assertThat(responseFuture.getResponseCommand().getLanguage()).isEqualTo(LanguageCode.JAVA);
            assertThat(responseFuture.getResponseCommand().getExtFields()).hasSize(2);
        }
    });
    latch.await();
}
 
Example #7
Source File: AdminBrokerProcessor.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
public RemotingCommand resetOffset(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final ResetOffsetRequestHeader requestHeader =
        (ResetOffsetRequestHeader) request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
    log.info("[reset-offset] reset offset started by {}. topic={}, group={}, timestamp={}, isForce={}",
        RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup(),
        requestHeader.getTimestamp(), requestHeader.isForce());
    boolean isC = false;
    LanguageCode language = request.getLanguage();
    switch (language) {
        case CPP:
            isC = true;
            break;
    }
    return this.brokerController.getBroker2Client().resetOffset(requestHeader.getTopic(), requestHeader.getGroup(),
        requestHeader.getTimestamp(), requestHeader.isForce(), isC);
}
 
Example #8
Source File: RemotingServerTest.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
@Test
public void testInvokeAsync() throws InterruptedException, RemotingConnectException,
    RemotingTimeoutException, RemotingTooMuchRequestException, RemotingSendRequestException {

    final CountDownLatch latch = new CountDownLatch(1);
    RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
    request.setRemark("messi");
    remotingClient.invokeAsync("localhost:8888", request, 1000 * 3, new InvokeCallback() {
        @Override
        public void operationComplete(ResponseFuture responseFuture) {
            latch.countDown();
            assertTrue(responseFuture != null);
            assertThat(responseFuture.getResponseCommand().getLanguage()).isEqualTo(LanguageCode.JAVA);
            assertThat(responseFuture.getResponseCommand().getExtFields()).hasSize(2);
        }
    });
    latch.await();
}
 
Example #9
Source File: RemotingServerTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testInvokeAsync() throws InterruptedException, RemotingConnectException,
    RemotingTimeoutException, RemotingTooMuchRequestException, RemotingSendRequestException {

    final CountDownLatch latch = new CountDownLatch(1);
    RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
    request.setRemark("messi");
    remotingClient.invokeAsync("localhost:8888", request, 1000 * 3, new InvokeCallback() {
        @Override
        public void operationComplete(ResponseFuture responseFuture) {
            latch.countDown();
            assertTrue(responseFuture != null);
            assertThat(responseFuture.getResponseCommand().getLanguage()).isEqualTo(LanguageCode.JAVA);
            assertThat(responseFuture.getResponseCommand().getExtFields()).hasSize(2);
        }
    });
    latch.await();
}
 
Example #10
Source File: ClientManageProcessorTest.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
@Before
public void init() {
    when(handlerContext.channel()).thenReturn(channel);
    clientManageProcessor = new ClientManageProcessor(brokerController);
    clientChannelInfo = new ClientChannelInfo(channel, clientId, LanguageCode.JAVA, 100);
    brokerController.getProducerManager().registerProducer(group, clientChannelInfo);

    ConsumerData consumerData = createConsumerData(group, topic);
    brokerController.getConsumerManager().registerConsumer(
        consumerData.getGroupName(),
        clientChannelInfo,
        consumerData.getConsumeType(),
        consumerData.getMessageModel(),
        consumerData.getConsumeFromWhere(),
        consumerData.getSubscriptionDataSet(),
        false);
}
 
Example #11
Source File: AbstractOMSProducer.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
AbstractOMSProducer(final KeyValue properties) {
    this.properties = properties;
    this.rocketmqProducer = new DefaultMQProducer();
    this.clientConfig = BeanUtils.populate(properties, ClientConfig.class);

    if ("true".equalsIgnoreCase(System.getenv("OMS_RMQ_DIRECT_NAME_SRV"))) {
        String accessPoints = clientConfig.getAccessPoints();
        if (accessPoints == null || accessPoints.isEmpty()) {
            throw new OMSRuntimeException("-1", "OMS AccessPoints is null or empty.");
        }

        this.rocketmqProducer.setNamesrvAddr(accessPoints.replace(',', ';'));
    }

    this.rocketmqProducer.setProducerGroup(clientConfig.getRmqProducerGroup());

    String producerId = buildInstanceName();
    this.rocketmqProducer.setSendMsgTimeout(clientConfig.getOperationTimeout());
    this.rocketmqProducer.setInstanceName(producerId);
    this.rocketmqProducer.setMaxMessageSize(1024 * 1024 * 4);
    this.rocketmqProducer.setLanguage(LanguageCode.OMS);
    properties.put(OMSBuiltinKeys.PRODUCER_ID, producerId);
}
 
Example #12
Source File: RemotingServerTest.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@Test
public void testInvokeAsync() throws InterruptedException, RemotingConnectException,
    RemotingTimeoutException, RemotingTooMuchRequestException, RemotingSendRequestException {

    final CountDownLatch latch = new CountDownLatch(1);
    RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
    request.setRemark("messi");
    remotingClient.invokeAsync("localhost:8888", request, 1000 * 3, new InvokeCallback() {
        @Override
        public void operationComplete(ResponseFuture responseFuture) {
            latch.countDown();
            assertTrue(responseFuture != null);
            assertThat(responseFuture.getResponseCommand().getLanguage()).isEqualTo(LanguageCode.JAVA);
            assertThat(responseFuture.getResponseCommand().getExtFields()).hasSize(2);
        }
    });
    latch.await();
}
 
Example #13
Source File: ClientManageProcessorTest.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
@Before
public void init() {
    when(handlerContext.channel()).thenReturn(channel);
    clientManageProcessor = new ClientManageProcessor(brokerController);
    clientChannelInfo = new ClientChannelInfo(channel, clientId, LanguageCode.JAVA, 100);
    brokerController.getProducerManager().registerProducer(group, clientChannelInfo);

    ConsumerData consumerData = createConsumerData(group, topic);
    brokerController.getConsumerManager().registerConsumer(
        consumerData.getGroupName(),
        clientChannelInfo,
        consumerData.getConsumeType(),
        consumerData.getMessageModel(),
        consumerData.getConsumeFromWhere(),
        consumerData.getSubscriptionDataSet(),
        false);
}
 
Example #14
Source File: ClientManageProcessorTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Before
public void init() {
    when(handlerContext.channel()).thenReturn(channel);
    clientManageProcessor = new ClientManageProcessor(brokerController);
    clientChannelInfo = new ClientChannelInfo(channel, clientId, LanguageCode.JAVA, 100);
    brokerController.getProducerManager().registerProducer(group, clientChannelInfo);

    ConsumerData consumerData = createConsumerData(group, topic);
    brokerController.getConsumerManager().registerConsumer(
        consumerData.getGroupName(),
        clientChannelInfo,
        consumerData.getConsumeType(),
        consumerData.getMessageModel(),
        consumerData.getConsumeFromWhere(),
        consumerData.getSubscriptionDataSet(),
        false);
}
 
Example #15
Source File: QueryMsgByUniqueKeySubCommandTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testExecuteConsumeActively() throws SubCommandException, InterruptedException, MQBrokerException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException {

    ConsumerConnection consumerConnection = new ConsumerConnection();
    consumerConnection.setConsumeType(ConsumeType.CONSUME_ACTIVELY);
    HashSet<Connection> connectionSet = new HashSet<>();
    Connection conn = new Connection();
    conn.setClientId("clientIdTest");
    conn.setClientAddr("clientAddrTest");
    conn.setLanguage(LanguageCode.JAVA);
    conn.setVersion(1);
    connectionSet.add(conn);
    consumerConnection.setConnectionSet(connectionSet);
    when(mQClientAPIImpl.getConsumerConnectionList(anyString(), anyString(), anyLong())).thenReturn(consumerConnection);

    Options options = ServerUtil.buildCommandlineOptions(new Options());

    String[] args = new String[]{"-t myTopicTest", "-i msgId"};
    CommandLine commandLine = ServerUtil.parseCmdLine("mqadmin ", args, cmd.buildCommandlineOptions(options), new PosixParser());
    cmd.execute(commandLine, options, null);

}
 
Example #16
Source File: ClientManageProcessorTest.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@Before
public void init() {
    when(handlerContext.channel()).thenReturn(channel);
    clientManageProcessor = new ClientManageProcessor(brokerController);
    clientChannelInfo = new ClientChannelInfo(channel, clientId, LanguageCode.JAVA, 100);
    brokerController.getProducerManager().registerProducer(group, clientChannelInfo);

    ConsumerData consumerData = createConsumerData(group, topic);
    brokerController.getConsumerManager().registerConsumer(
        consumerData.getGroupName(),
        clientChannelInfo,
        consumerData.getConsumeType(),
        consumerData.getMessageModel(),
        consumerData.getConsumeFromWhere(),
        consumerData.getSubscriptionDataSet(),
        false);
}
 
Example #17
Source File: RemotingServerTest.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
@Test
public void testInvokeAsync() throws InterruptedException, RemotingConnectException,
    RemotingTimeoutException, RemotingTooMuchRequestException, RemotingSendRequestException {

    final CountDownLatch latch = new CountDownLatch(1);
    RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
    request.setRemark("messi");
    remotingClient.invokeAsync("localhost:8888", request, 1000 * 3, new InvokeCallback() {
        @Override
        public void operationComplete(ResponseFuture responseFuture) {
            latch.countDown();
            assertTrue(responseFuture != null);
            assertThat(responseFuture.getResponseCommand().getLanguage()).isEqualTo(LanguageCode.JAVA);
            assertThat(responseFuture.getResponseCommand().getExtFields()).hasSize(2);
        }
    });
    latch.await();
}
 
Example #18
Source File: RemotingServerTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Test
public void testInvokeAsync() throws InterruptedException, RemotingConnectException,
    RemotingTimeoutException, RemotingTooMuchRequestException, RemotingSendRequestException {

    final CountDownLatch latch = new CountDownLatch(1);
    RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
    request.setRemark("messi");
    remotingClient.invokeAsync("localhost:8888", request, 1000 * 3, new InvokeCallback() {
        @Override
        public void operationComplete(ResponseFuture responseFuture) {
            latch.countDown();
            assertTrue(responseFuture != null);
            assertThat(responseFuture.getResponseCommand().getLanguage()).isEqualTo(LanguageCode.JAVA);
            assertThat(responseFuture.getResponseCommand().getExtFields()).hasSize(2);
        }
    });
    latch.await();
}
 
Example #19
Source File: AdminBrokerProcessor.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
public RemotingCommand resetOffset(ChannelHandlerContext ctx,
    RemotingCommand request) throws RemotingCommandException {
    final ResetOffsetRequestHeader requestHeader =
        (ResetOffsetRequestHeader) request.decodeCommandCustomHeader(ResetOffsetRequestHeader.class);
    log.info("[reset-offset] reset offset started by {}. topic={}, group={}, timestamp={}, isForce={}",
        RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getTopic(), requestHeader.getGroup(),
        requestHeader.getTimestamp(), requestHeader.isForce());
    boolean isC = false;
    LanguageCode language = request.getLanguage();
    switch (language) {
        case CPP:
            isC = true;
            break;
    }
    return this.brokerController.getBroker2Client().resetOffset(requestHeader.getTopic(), requestHeader.getGroup(),
        requestHeader.getTimestamp(), requestHeader.isForce(), isC);
}
 
Example #20
Source File: PullConsumerImpl.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
public PullConsumerImpl(final KeyValue properties) {
    this.properties = properties;
    this.clientConfig = BeanUtils.populate(properties, ClientConfig.class);

    String consumerGroup = clientConfig.getConsumerId();
    if (null == consumerGroup || consumerGroup.isEmpty()) {
        throw new OMSRuntimeException("-1", "Consumer Group is necessary for RocketMQ, please set it.");
    }
    pullConsumerScheduleService = new MQPullConsumerScheduleService(consumerGroup);

    this.rocketmqPullConsumer = pullConsumerScheduleService.getDefaultMQPullConsumer();

    if ("true".equalsIgnoreCase(System.getenv("OMS_RMQ_DIRECT_NAME_SRV"))) {
        String accessPoints = clientConfig.getAccessPoints();
        if (accessPoints == null || accessPoints.isEmpty()) {
            throw new OMSRuntimeException("-1", "OMS AccessPoints is null or empty.");
        }
        this.rocketmqPullConsumer.setNamesrvAddr(accessPoints.replace(',', ';'));
    }

    this.rocketmqPullConsumer.setConsumerGroup(consumerGroup);

    int maxReDeliveryTimes = clientConfig.getRmqMaxRedeliveryTimes();
    this.rocketmqPullConsumer.setMaxReconsumeTimes(maxReDeliveryTimes);

    String consumerId = OMSUtil.buildInstanceName();
    this.rocketmqPullConsumer.setInstanceName(consumerId);
    properties.put(OMSBuiltinKeys.CONSUMER_ID, consumerId);

    this.rocketmqPullConsumer.setLanguage(LanguageCode.OMS);

    this.localMessageCache = new LocalMessageCache(this.rocketmqPullConsumer, clientConfig);
}
 
Example #21
Source File: TlsTest.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
private void requestThenAssertResponse(RemotingClient remotingClient) throws Exception {
    RemotingCommand response = remotingClient.invokeSync("localhost:8888", createRequest(), 1000 * 3);
    assertTrue(response != null);
    assertThat(response.getLanguage()).isEqualTo(LanguageCode.JAVA);
    assertThat(response.getExtFields()).hasSize(2);
    assertThat(response.getExtFields().get("messageTitle")).isEqualTo("Welcome");
}
 
Example #22
Source File: RemotingServerTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
public void testInvokeSync() throws InterruptedException, RemotingConnectException,
    RemotingSendRequestException, RemotingTimeoutException {
    RequestHeader requestHeader = new RequestHeader();
    requestHeader.setCount(1);
    requestHeader.setMessageTitle("Welcome");
    RemotingCommand request = RemotingCommand.createRequestCommand(0, requestHeader);
    RemotingCommand response = remotingClient.invokeSync("localhost:8888", request, 1000 * 3);
    assertTrue(response != null);
    assertThat(response.getLanguage()).isEqualTo(LanguageCode.JAVA);
    assertThat(response.getExtFields()).hasSize(2);

}
 
Example #23
Source File: ClientManageProcessorTest.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
private RemotingCommand createUnRegisterConsumerCommand() {
    UnregisterClientRequestHeader requestHeader = new UnregisterClientRequestHeader();
    requestHeader.setClientID(clientId);
    requestHeader.setConsumerGroup(group);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UNREGISTER_CLIENT, requestHeader);
    request.setLanguage(LanguageCode.JAVA);
    request.setVersion(100);
    request.makeCustomHeaderToNet();
    return request;
}
 
Example #24
Source File: ClientManageProcessorTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private RemotingCommand createUnRegisterProducerCommand() {
    UnregisterClientRequestHeader requestHeader = new UnregisterClientRequestHeader();
    requestHeader.setClientID(clientId);
    requestHeader.setProducerGroup(group);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UNREGISTER_CLIENT, requestHeader);
    request.setLanguage(LanguageCode.JAVA);
    request.setVersion(100);
    request.makeCustomHeaderToNet();
    return request;
}
 
Example #25
Source File: ClientManageProcessorTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private RemotingCommand createUnRegisterConsumerCommand() {
    UnregisterClientRequestHeader requestHeader = new UnregisterClientRequestHeader();
    requestHeader.setClientID(clientId);
    requestHeader.setConsumerGroup(group);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UNREGISTER_CLIENT, requestHeader);
    request.setLanguage(LanguageCode.JAVA);
    request.setVersion(100);
    request.makeCustomHeaderToNet();
    return request;
}
 
Example #26
Source File: DeFiConsumerManagerTest.java    From DeFiBus with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
    deFiConsumerManager = new DeFiConsumerManager(consumerIdsChangeListener, adjustQueueNumStrategy);
    mockChannel = mock(Channel.class);
    clientChannelInfo = new ClientChannelInfo(mockChannel, clientId, LanguageCode.JAVA, 100);
    consumerData = createConsumerData(group, topic);
    deFiConsumerManager.registerConsumer(consumerData.getGroupName(),
        clientChannelInfo,
        consumerData.getConsumeType(),
        consumerData.getMessageModel(),
        consumerData.getConsumeFromWhere(),
        consumerData.getSubscriptionDataSet(),
        false);
}
 
Example #27
Source File: ClientManageProcessorTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
private RemotingCommand createUnRegisterProducerCommand() {
    UnregisterClientRequestHeader requestHeader = new UnregisterClientRequestHeader();
    requestHeader.setClientID(clientId);
    requestHeader.setProducerGroup(group);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.UNREGISTER_CLIENT, requestHeader);
    request.setLanguage(LanguageCode.JAVA);
    request.setVersion(100);
    request.makeCustomHeaderToNet();
    return request;
}
 
Example #28
Source File: TlsTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
private void requestThenAssertResponse() throws Exception {
    RemotingCommand response = remotingClient.invokeSync("localhost:8888", createRequest(), 1000 * 3);
    assertTrue(response != null);
    assertThat(response.getLanguage()).isEqualTo(LanguageCode.JAVA);
    assertThat(response.getExtFields()).hasSize(2);
    assertThat(response.getExtFields().get("messageTitle")).isEqualTo("Welcome");
}
 
Example #29
Source File: PullConsumerImpl.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public PullConsumerImpl(final KeyValue properties) {
    this.properties = properties;
    this.clientConfig = BeanUtils.populate(properties, ClientConfig.class);

    String consumerGroup = clientConfig.getConsumerId();
    if (null == consumerGroup || consumerGroup.isEmpty()) {
        throw new OMSRuntimeException("-1", "Consumer Group is necessary for RocketMQ, please set it.");
    }
    pullConsumerScheduleService = new MQPullConsumerScheduleService(consumerGroup);

    this.rocketmqPullConsumer = pullConsumerScheduleService.getDefaultMQPullConsumer();

    if ("true".equalsIgnoreCase(System.getenv("OMS_RMQ_DIRECT_NAME_SRV"))) {
        String accessPoints = clientConfig.getAccessPoints();
        if (accessPoints == null || accessPoints.isEmpty()) {
            throw new OMSRuntimeException("-1", "OMS AccessPoints is null or empty.");
        }
        this.rocketmqPullConsumer.setNamesrvAddr(accessPoints.replace(',', ';'));
    }

    this.rocketmqPullConsumer.setConsumerGroup(consumerGroup);

    int maxReDeliveryTimes = clientConfig.getRmqMaxRedeliveryTimes();
    this.rocketmqPullConsumer.setMaxReconsumeTimes(maxReDeliveryTimes);

    String consumerId = OMSUtil.buildInstanceName();
    this.rocketmqPullConsumer.setInstanceName(consumerId);
    properties.put(OMSBuiltinKeys.CONSUMER_ID, consumerId);

    this.rocketmqPullConsumer.setLanguage(LanguageCode.OMS);

    this.localMessageCache = new LocalMessageCache(this.rocketmqPullConsumer, clientConfig);
}
 
Example #30
Source File: DeFiClientManageProcessorTest.java    From DeFiBus with Apache License 2.0 5 votes vote down vote up
private RemotingCommand GetConsumerListCommand() {
    GetConsumerListByGroupAndTopicRequestHeader requestHeader = new GetConsumerListByGroupAndTopicRequestHeader();
    requestHeader.setConsumerGroup(group);
    requestHeader.setTopic(topic);
    RemotingCommand request = RemotingCommand.createRequestCommand(DeFiBusRequestCode.GET_CONSUMER_LIST_BY_GROUP_AND_TOPIC, requestHeader);
    request.setLanguage(LanguageCode.JAVA);
    request.setVersion(100);
    request.makeCustomHeaderToNet();
    return request;
}