本文整理汇总了Java中com.amazon.sqs.javamessaging.SQSConnectionFactory.createConnection方法的典型用法代码示例。如果您正苦于以下问题:Java SQSConnectionFactory.createConnection方法的具体用法?Java SQSConnectionFactory.createConnection怎么用?Java SQSConnectionFactory.createConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazon.sqs.javamessaging.SQSConnectionFactory
的用法示例。
在下文中一共展示了SQSConnectionFactory.createConnection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sqsConnection
import com.amazon.sqs.javamessaging.SQSConnectionFactory; //导入方法依赖的package包/类
@Bean
public SQSConnection sqsConnection(final AWSCredentialsProvider awsCredentialsProvider,
final ClientConfiguration awsClientConfig, final Region awsRegion) throws JMSException {
SQSConnectionFactory connectionFactory = SQSConnectionFactory.builder()
.withRegion(awsRegion) //Gets region form meta data
.withAWSCredentialsProvider(awsCredentialsProvider)
.withClientConfiguration(awsClientConfig)
.build();
return connectionFactory.createConnection();
}
示例2: sqsConnection
import com.amazon.sqs.javamessaging.SQSConnectionFactory; //导入方法依赖的package包/类
@Bean
public SQSConnection sqsConnection(AWSCredentialsProvider awsCredentialsProvider,
ClientConfiguration awsClientConfig) throws JMSException {
SQSConnectionFactory connectionFactory = SQSConnectionFactory.builder()
.withRegion(RegionUtils.getRegion(awsRegion))
.withAWSCredentialsProvider(awsCredentialsProvider)
.withClientConfiguration(awsClientConfig)
.build();
return connectionFactory.createConnection();
}
示例3: init
import com.amazon.sqs.javamessaging.SQSConnectionFactory; //导入方法依赖的package包/类
public void init(AWSKafkaConfig config){
this.config = config;
deDuplicationId = config.getDeDeupPrefix();
mXmitDisable = config.getAwsXmitDisable();
SQSConnectionFactory connectionFactory = new SQSConnectionFactory(
new ProviderConfiguration(),
AmazonSQSClientBuilder.standard()
.withRegion(config.getRegions())
.withCredentials(config.getCredentialsProvider())
);
try{
mPreProcessor = config.getPre();
mXmitReplacement = config.getReplaceXmit(this);
// Create the connection.
connection = connectionFactory.createConnection();
// Create the queue if needed
//ExampleCommon.ensureQueueExists(connection, config.getQueueName());
// Create the session
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
producer = session.createProducer( session.createQueue( config.getQueueName() ) );
// Get the wrapped client
AmazonSQSMessagingClientWrapper client = connection.getWrappedAmazonSQSClient();
// Create an Amazon SQS queue if it does not already exist
if (!client.queueExists(config.getQueueName())) {
Map<String, String> attributes = new HashMap<String, String>();
attributes.put(config.getQueueName(), "true");
attributes.put("ContentBasedDeduplication", "true");
client.createQueue(new CreateQueueRequest().withQueueName(config.getQueueName()).withAttributes(attributes));
}
}catch(JMSException e){
}
}