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


Java Symbol类代码示例

本文整理汇总了Java中org.apache.qpid.proton.amqp.Symbol的典型用法代码示例。如果您正苦于以下问题:Java Symbol类的具体用法?Java Symbol怎么用?Java Symbol使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: connectHandler

import org.apache.qpid.proton.amqp.Symbol; //导入依赖的package包/类
private void connectHandler(ProtonConnection connection) {
    String containerId = "auth-server";
    connection.setContainer(containerId);
    connection.openHandler(conn -> {
        Map<Symbol, Object> props = new HashMap<>();
        Map<String, Object> claims = new HashMap<>();
        claims.put("sub", saslAuthenticator.getUser());
        claims.put("preferred_username", saslAuthenticator.getUser());
        props.put(Symbol.valueOf("authenticated-identity"),claims);

        if(groups.containsKey(saslAuthenticator.getUser())) {
            props.put(Symbol.valueOf("groups"), groups.get(saslAuthenticator.getUser()));
        }
        connection.setProperties(props);
        connection.open();
        connection.close();
    }).closeHandler(conn -> {
        connection.close();
        connection.disconnect();
    }).disconnectHandler(protonConnection -> {
        connection.disconnect();
    });

}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:25,代码来源:SaslDelegatingLoginTest.java

示例2: recvMessages

import org.apache.qpid.proton.amqp.Symbol; //导入依赖的package包/类
public CompletableFuture<List<String>> recvMessages(long numMessages, long attachTimeout, TimeUnit timeUnit) throws InterruptedException {
    CountDownLatch latch = new CountDownLatch(1);
    CompletableFuture<List<String>> future = new CompletableFuture<>();
    List<String> messages = new ArrayList<>();
    protonClient.connect("localhost", protonServer.actualPort(), event -> {
        ProtonConnection connection = event.result().open();
        Source source = new Source();
        source.setAddress(address);
        source.setCapabilities(Symbol.getSymbol("topic"));
        connection.createReceiver(address)
                .openHandler(opened -> latch.countDown())
                .setSource(source)
                .handler((delivery, message) -> {
                    messages.add((String) ((AmqpValue) message.getBody()).getValue());
                    if (messages.size() == numMessages) {
                        future.complete(new ArrayList<>(messages));
                    }
                })
                .open();
    });
    latch.await(attachTimeout, timeUnit);
    return future;
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:24,代码来源:TestBroker.java

示例3: subscribe

import org.apache.qpid.proton.amqp.Symbol; //导入依赖的package包/类
public void subscribe(String address, Async subClosed, ProtonMessageHandler handler) {
    client.connect(new ProtonClientOptions().setConnectTimeout(10000), serverHost, serverPort, connectResult -> {
        if (connectResult.succeeded()) {
            System.out.println("Connected'");
            connection = connectResult.result();
            connection.closeHandler(c -> closeLatch.countDown());
            connection.open();
            System.out.println("Creating receiver");
            Source source = new Source();
            source.setAddress(address);
            Map<Symbol, Map<String, String>> filter = new LinkedHashMap<>();
            filter.put(Symbol.getSymbol("labels"), Collections.singletonMap("my", "label"));
            filter.put(Symbol.getSymbol("annotations"), Collections.singletonMap("my", "annotation"));
            source.setFilter(filter);
            connection.createReceiver(address).setSource(source).closeHandler(c -> {if (subClosed != null) { subClosed.complete(); }}).handler(handler).open();
        } else {
            System.out.println("Connection failed: " + connectResult.cause().getMessage());
        }
    });
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:21,代码来源:TestClient.java

示例4: toMessage

import org.apache.qpid.proton.amqp.Symbol; //导入依赖的package包/类
@Override
public Message toMessage(String address, ConsumerRecord<String, byte[]> record) {
	
	Message message = Proton.message();
	message.setAddress(address);
	
	// put message annotations about partition, offset and key (if not null)
	Map<Symbol, Object> map = new HashMap<>();
	map.put(Symbol.valueOf(AmqpBridge.AMQP_PARTITION_ANNOTATION), record.partition());
	map.put(Symbol.valueOf(AmqpBridge.AMQP_OFFSET_ANNOTATION), record.offset());
	if (record.key() != null)
		map.put(Symbol.valueOf(AmqpBridge.AMQP_KEY_ANNOTATION), record.key());
	map.put(Symbol.valueOf(AmqpBridge.AMQP_TOPIC_ANNOTATION), record.topic());
	
	MessageAnnotations messageAnnotations = new MessageAnnotations(map);
	message.setMessageAnnotations(messageAnnotations);
	
	message.setBody(new Data(new Binary(record.value())));
	
	return message;
}
 
开发者ID:strimzi,项目名称:amqp-kafka-bridge,代码行数:22,代码来源:AmqpDefaultMessageConverter.java

示例5: newInstance

import org.apache.qpid.proton.amqp.Symbol; //导入依赖的package包/类
public SaslMechanisms newInstance(Object described)
{
    List l = (List) described;

    SaslMechanisms o = new SaslMechanisms();

    if(l.isEmpty())
    {
        throw new DecodeException("The sasl-server-mechanisms field cannot be omitted");
    }

    Object val0 = l.get( 0 );
    if( val0 == null || val0.getClass().isArray() )
    {
        o.setSaslServerMechanisms( (Symbol[]) val0 );
    }
    else
    {
        o.setSaslServerMechanisms( (Symbol) val0 );
    }

    return o;
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:24,代码来源:SaslMechanismsType.java

示例6: filters_nonIntegerPartitionFilter

import org.apache.qpid.proton.amqp.Symbol; //导入依赖的package包/类
/** When happens when partition filter is not an Integer? */
@Test
public <K, V> void filters_nonIntegerPartitionFilter() throws Exception {
	String topic = "my_topic";
	Vertx vertx = Vertx.vertx();
	AmqpSinkBridgeEndpoint<K,V> endpoint = new AmqpSinkBridgeEndpoint<K,V>(vertx, new AmqpBridgeConfigProperties());
	endpoint.open();
	ProtonSender mockSender = mockSender(ProtonQoS.AT_MOST_ONCE, topic+"/group.id/blah");
	// Call handle()
	Map<Symbol, Object> filter = new HashMap<>();
	filter.put(Symbol.getSymbol(AmqpBridge.AMQP_PARTITION_FILTER), "not an integer");
	filter.put(Symbol.getSymbol(AmqpBridge.AMQP_OFFSET_FILTER), 10L);
	((Source)mockSender.getRemoteSource()).setFilter(filter);
	endpoint.handle(new AmqpEndpoint(mockSender));
	
	assertDetach(mockSender, 
			AmqpBridge.AMQP_ERROR_WRONG_PARTITION_FILTER,
			"Wrong partition filter");
}
 
开发者ID:strimzi,项目名称:amqp-kafka-bridge,代码行数:20,代码来源:AmqpSinkBridgeEndpointMockTest.java

示例7: filters_negativeIntegerPartitionFilter

import org.apache.qpid.proton.amqp.Symbol; //导入依赖的package包/类
/** When happens when the partition filter &lt; 0? */
@Test
public <K, V> void filters_negativeIntegerPartitionFilter() throws Exception {
	String topic = "my_topic";
	Vertx vertx = Vertx.vertx();
	AmqpSinkBridgeEndpoint<K,V> endpoint = new AmqpSinkBridgeEndpoint<K,V>(vertx, new AmqpBridgeConfigProperties());
	endpoint.open();
	ProtonSender mockSender = mockSender(ProtonQoS.AT_MOST_ONCE, topic+"/group.id/blah");
	// Call handle()
	Map<Symbol, Object> filter = new HashMap<>();
	filter.put(Symbol.getSymbol(AmqpBridge.AMQP_PARTITION_FILTER), -1);
	filter.put(Symbol.getSymbol(AmqpBridge.AMQP_OFFSET_FILTER), 10L);
	((Source)mockSender.getRemoteSource()).setFilter(filter);
	endpoint.handle(new AmqpEndpoint(mockSender));
	
	ArgumentCaptor<ErrorCondition> errorCap = ArgumentCaptor.forClass(ErrorCondition.class);
	verify(mockSender).setCondition(errorCap.capture());
	verify(mockSender).close();
	
	assertDetach(mockSender, 
			AmqpBridge.AMQP_ERROR_WRONG_FILTER,
			"Wrong filter");
}
 
开发者ID:strimzi,项目名称:amqp-kafka-bridge,代码行数:24,代码来源:AmqpSinkBridgeEndpointMockTest.java

示例8: filters_negativeLongOffsetFilter

import org.apache.qpid.proton.amqp.Symbol; //导入依赖的package包/类
/** When happens when the offset filter is &lt; 0? */
@Test
public <K, V> void filters_negativeLongOffsetFilter() throws Exception {
	String topic = "my_topic";
	Vertx vertx = Vertx.vertx();
	AmqpSinkBridgeEndpoint<K,V> endpoint = new AmqpSinkBridgeEndpoint<K,V>(vertx, new AmqpBridgeConfigProperties());
	endpoint.open();
	ProtonSender mockSender = mockSender(ProtonQoS.AT_MOST_ONCE, topic+"/group.id/blah");
	// Call handle()
	Map<Symbol, Object> filter = new HashMap<>();
	filter.put(Symbol.getSymbol(AmqpBridge.AMQP_PARTITION_FILTER), 0);
	filter.put(Symbol.getSymbol(AmqpBridge.AMQP_OFFSET_FILTER), -10L);
	((Source)mockSender.getRemoteSource()).setFilter(filter);
	endpoint.handle(new AmqpEndpoint(mockSender));
	
	assertDetach(mockSender, 
			AmqpBridge.AMQP_ERROR_WRONG_FILTER,
			"Wrong filter");
}
 
开发者ID:strimzi,项目名称:amqp-kafka-bridge,代码行数:20,代码来源:AmqpSinkBridgeEndpointMockTest.java

示例9: filters_offsetFilterButNoPartitionFilter

import org.apache.qpid.proton.amqp.Symbol; //导入依赖的package包/类
/** When happens when there's a filter for offset, but not for partition? */
@Test
public <K, V> void filters_offsetFilterButNoPartitionFilter() throws Exception {
	String topic = "my_topic";
	Vertx vertx = Vertx.vertx();
	AmqpSinkBridgeEndpoint<K,V> endpoint = new AmqpSinkBridgeEndpoint<K,V>(vertx, new AmqpBridgeConfigProperties());
	endpoint.open();
	ProtonSender mockSender = mockSender(ProtonQoS.AT_MOST_ONCE, topic+"/group.id/blah");
	// Call handle()
	Map<Symbol, Object> filter = new HashMap<>();
	//filter.put(Symbol.getSymbol(Bridge.AMQP_PARTITION_FILTER), 0);
	filter.put(Symbol.getSymbol(AmqpBridge.AMQP_OFFSET_FILTER), 10L);
	((Source)mockSender.getRemoteSource()).setFilter(filter);
	endpoint.handle(new AmqpEndpoint(mockSender));
	
	assertDetach(mockSender, 
			AmqpBridge.AMQP_ERROR_NO_PARTITION_FILTER,
			"No partition filter specified");
}
 
开发者ID:strimzi,项目名称:amqp-kafka-bridge,代码行数:20,代码来源:AmqpSinkBridgeEndpointMockTest.java

示例10: newInstance

import org.apache.qpid.proton.amqp.Symbol; //导入依赖的package包/类
public SaslInit newInstance(Object described)
{
    List l = (List) described;

    SaslInit o = new SaslInit();

    if(l.size() <= 0)
    {
        throw new DecodeException("The mechanism field cannot be omitted");
    }

    switch(3 - l.size())
    {

        case 0:
            o.setHostname( (String) l.get( 2 ) );
        case 1:
            o.setInitialResponse( (Binary) l.get( 1 ) );
        case 2:
            o.setMechanism( (Symbol) l.get( 0 ) );
    }


    return o;
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:26,代码来源:SaslInitType.java

示例11: testConditionAndDescriptionEquality

import org.apache.qpid.proton.amqp.Symbol; //导入依赖的package包/类
@Test
public void testConditionAndDescriptionEquality()
{
    String symbolValue = "symbol";
    String descriptionValue = "description";

    ErrorCondition same1 = new ErrorCondition();
    same1.setCondition(Symbol.getSymbol(new String(symbolValue)));
    same1.setDescription(new String(descriptionValue));

    ErrorCondition same2 = new ErrorCondition();
    same2.setCondition(Symbol.getSymbol(new String(symbolValue)));
    same2.setDescription(new String(descriptionValue));

    assertErrorConditionsEqual(same1, same2);

    ErrorCondition different = new ErrorCondition();
    different.setCondition(Symbol.getSymbol(symbolValue));
    different.setDescription("other");

    assertErrorConditionsNotEqual(same1, different);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:23,代码来源:ErrorConditionTest.java

示例12: readSymbol

import org.apache.qpid.proton.amqp.Symbol; //导入依赖的package包/类
public Symbol readSymbol(final Symbol defaultValue)
{
    byte encodingCode = _buffer.get();

    switch (encodingCode)
    {
        case EncodingCodes.SYM8:
            return (Symbol) _constructors[EncodingCodes.SYM8 & 0xff].readValue();
        case EncodingCodes.SYM32:
            return (Symbol) _constructors[EncodingCodes.SYM32 & 0xff].readValue();
        case EncodingCodes.NULL:
            return defaultValue;
        default:
            throw new ProtonException("Expected Symbol type but found encoding: " + encodingCode);
    }
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:17,代码来源:DecoderImpl.java

示例13: testConditionEquality

import org.apache.qpid.proton.amqp.Symbol; //导入依赖的package包/类
@Test
public void testConditionEquality()
{
    String symbolValue = "symbol";

    ErrorCondition same1 = new ErrorCondition();
    same1.setCondition(Symbol.getSymbol(new String(symbolValue)));

    ErrorCondition same2 = new ErrorCondition();
    same2.setCondition(Symbol.getSymbol(new String(symbolValue)));

    assertErrorConditionsEqual(same1, same2);

    ErrorCondition different = new ErrorCondition();
    different.setCondition(Symbol.getSymbol("other"));

    assertErrorConditionsNotEqual(same1, different);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:19,代码来源:ErrorConditionTest.java

示例14: testEncodeDecodeSymbolArrayUsingPutObject

import org.apache.qpid.proton.amqp.Symbol; //导入依赖的package包/类
@Test
public void testEncodeDecodeSymbolArrayUsingPutObject()
{
    Symbol symbol1 = Symbol.valueOf("testRoundtripSymbolArray1");
    Symbol symbol2 = Symbol.valueOf("testRoundtripSymbolArray2");
    Symbol[] input = new Symbol[]{symbol1, symbol2};

    Data data1 = new DataImpl();
    data1.putObject(input);

    Binary encoded = data1.encode();
    encoded.asByteBuffer();

    Data data2 = new DataImpl();
    data2.decode(encoded.asByteBuffer());

    assertEquals("unexpected array length", 2, data2.getArray());
    assertEquals("unexpected array length", Data.DataType.SYMBOL, data2.getArrayType());

    Object[] array = data2.getJavaArray();
    assertArrayEquals("Array not as expected", input, array);
}
 
开发者ID:apache,项目名称:qpid-proton-j,代码行数:23,代码来源:DataImplTest.java

示例15: assertMessageAnnotationsContainProperties

import org.apache.qpid.proton.amqp.Symbol; //导入依赖的package包/类
private void assertMessageAnnotationsContainProperties(final Message msg, final String tenantId,
        final String deviceId) {
    assertNotNull(msg.getMessageAnnotations());
    assertThat(msg.getMessageAnnotations().getValue().get(Symbol.valueOf(MessageHelper.APP_PROPERTY_TENANT_ID)),
            is(tenantId));
    assertThat(msg.getMessageAnnotations().getValue().get(Symbol.valueOf(MessageHelper.APP_PROPERTY_DEVICE_ID)),
            is(deviceId));
    final ResourceIdentifier expectedResourceIdentifier = getResourceIdentifier(MY_TENANT, MY_DEVICE);
    assertThat(msg.getMessageAnnotations().getValue().get(Symbol.valueOf(APP_PROPERTY_RESOURCE)),
            is(expectedResourceIdentifier.toString()));
}
 
开发者ID:eclipse,项目名称:hono,代码行数:12,代码来源:HonoMessagingMessageFilterTest.java


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