• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LongString类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getValidRabbitMQHeaderValue

import com.rabbitmq.client.LongString; //导入依赖的package包/类
/**
 * Strategy to test if the given header is valid. Without this, the
 * com.rabbitmq.client.impl.Frame.java class will throw an
 * IllegalArgumentException (invalid value in table) and close the
 * connection.
 *
 * @param headerValue the header value
 * @return the value to use, <tt>null</tt> to ignore this header
 * @see com.rabbitmq.client.impl.Frame#fieldValueSize
 */
private Object getValidRabbitMQHeaderValue(Object headerValue) {
    if (headerValue instanceof String) {
        return headerValue;
    } else if (headerValue instanceof Number) {
        return headerValue;
    } else if (headerValue instanceof Boolean) {
        return headerValue;
    } else if (headerValue instanceof Date) {
        return headerValue;
    } else if (headerValue instanceof byte[]) {
        return headerValue;
    } else if (headerValue instanceof LongString) {
        return headerValue;
    }

    return null;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:28,代码来源:RabbitMQMessageConverter.java


示例2: headers

import com.rabbitmq.client.LongString; //导入依赖的package包/类
static Map<String, Struct> headers(BasicProperties basicProperties) {
  Map<String, Object> input = basicProperties.getHeaders();
  Map<String, Struct> results = new LinkedHashMap<>();
  if (null != input) {
    for (Map.Entry<String, Object> kvp : input.entrySet()) {
      log.trace("headers() - key = '{}' value= '{}'", kvp.getKey(), kvp.getValue());
      final String field;
      final Object headerValue;

      if (kvp.getValue() instanceof LongString) {
        headerValue = kvp.getValue().toString();
      } else {
        headerValue = kvp.getValue();
      }

      if (!FIELD_LOOKUP.containsKey(headerValue.getClass())) {
        throw new DataException(
            String.format("Could not determine the type for field '%s' type '%s'", kvp.getKey(), headerValue.getClass().getName())
        );
      } else {
        field = FIELD_LOOKUP.get(headerValue.getClass());
      }

      log.trace("headers() - Storing value for header in field = '{}' as {}", field, field);

      Struct value = new Struct(SCHEMA_HEADER_VALUE)
          .put("type", field)
          .put(field, headerValue);
      results.put(kvp.getKey(), value);
    }
  }
  return results;
}
 
开发者ID:jcustenborder,项目名称:kafka-connect-rabbitmq,代码行数:34,代码来源:MessageConverter.java


示例3: populateMessageHeadersFromRabbitMQHeaders

import com.rabbitmq.client.LongString; //导入依赖的package包/类
private void populateMessageHeadersFromRabbitMQHeaders(final Message message, final AMQP.BasicProperties properties) {
    Map<String, Object> headers = properties.getHeaders();
    if (headers != null) {
        for (Map.Entry<String, Object> entry : headers.entrySet()) {
            // Convert LongStrings to String.
            if (entry.getValue() instanceof LongString) {
                message.setHeader(entry.getKey(), entry.getValue().toString());
            } else {
                message.setHeader(entry.getKey(), entry.getValue());
            }
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:RabbitMQMessageConverter.java


示例4: parseMessageHeaderIntoBackend

import com.rabbitmq.client.LongString; //导入依赖的package包/类
@Test
public void parseMessageHeaderIntoBackend() throws Exception {
	final Map<String, LongString> rabbitTraceeHeader = new HashMap<>();
	rabbitTraceeHeader.put(INVOCATION_ID_KEY, new TestLongString("Crazy ID"));

	unit.toMessageProperties(createRabbitHeaderWith(TPIC_HEADER, rabbitTraceeHeader), mock(Envelope.class), CHARSET_UTF8);

	assertThat(backend.copyToMap(), hasEntry(INVOCATION_ID_KEY, "Crazy ID"));
}
 
开发者ID:tracee,项目名称:tracee,代码行数:10,代码来源:TraceeMessagePropertiesConverterTest.java


示例5: fixAMQPTable

import com.rabbitmq.client.LongString; //导入依赖的package包/类
/**
 * Fixes a map so that we have valid data present
 *
 * @param m
 *
 * @return
 */
@SuppressWarnings("unchecked")
public static Map<String, Object> fixAMQPTable( Map<String, Object> m )
{
    if( m == null )
    {
        return Collections.emptyMap();
    }

    if( !m.isEmpty() )
    {
        Iterator<Map.Entry<String, Object>> it = m.entrySet().iterator();
        while( it.hasNext() )
        {
            Map.Entry<String, Object> e = it.next();
            Object value = e.getValue();
            // Convert certain types to supported ones otherwise
            if( value instanceof LongString )
            {
                e.setValue( value.toString() );
            }
            else if( value instanceof BigInteger )
            {
                // wrap in a decimal
                e.setValue( new BigDecimal( (BigInteger) value ) );
            }
            else if( value instanceof Map )
            {
                // Recurse
                e.setValue( fixAMQPTable( (Map<String, Object>) value ) );
            }
            else if( value instanceof Collection )
            {
                e.setValue( CollectionUtils.unmodifiableList( (Collection) value ) );
            }
            else if( !(value == null
                    || value instanceof String
                    || value instanceof Integer
                    || value instanceof BigDecimal
                    || value instanceof Date
                    || value instanceof Byte
                    || value instanceof Double
                    || value instanceof Float
                    || value instanceof Long
                    || value instanceof Short
                    || value instanceof Boolean
                    || value instanceof byte[]
                    || value instanceof List
                    || value instanceof Object[]) )
            {
                // Not one of the remaining valid types then remove it
                it.remove();
            }
        }
    }

    return m;
}
 
开发者ID:peter-mount,项目名称:opendata-common,代码行数:65,代码来源:RabbitMQ.java


示例6: getTransportHeaders

import com.rabbitmq.client.LongString; //导入依赖的package包/类
public static Map getTransportHeaders(RabbitMQMessage message) {
    Map<String, String> map = new HashMap<String, String>();

    // correlation ID
    if (message.getCorrelationId() != null) {
        map.put(RabbitMQConstants.CORRELATION_ID, message.getCorrelationId());
    }

    // if a AMQP message ID is found
    if (message.getMessageId() != null) {
        map.put(RabbitMQConstants.MESSAGE_ID, message.getMessageId());
    }

    // replyto destination name
    if (message.getReplyTo() != null) {
        String dest = message.getReplyTo();
        map.put(RabbitMQConstants.RABBITMQ_REPLY_TO, dest);
    }

    // any other transport properties / headers
    Map<String, Object> headers = message.getHeaders();
    if (headers != null && !headers.isEmpty()) {
        for (String headerName : headers.keySet()) {
            String value = new String(((LongString)(headers.get(headerName))).getBytes());
            map.put(headerName, value);
        }
    }

    return map;
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:31,代码来源:RabbitMQUtils.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileSizeLimitExceededException类代码示例发布时间:2022-05-23
下一篇:
Java LibraryContainer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap