You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jclouds.apache.org by Ignasi Barrera <na...@apache.org> on 2015/11/09 21:48:37 UTC
Re: Help on how to use JCloud API with SQS
Hi Max,
I haven't used that API, but in jclouds all APIs and providers are
instantiated the same way. You need to use the ContextBuilder [1] to
configure the provider, the credentials, and configuration properties
that may be required for some particular providers. In general, it
looks like:
TheApi api = ContextBuilder.newBuilder("api or provider id")
.credentials("identity", "credential")
.overrides(optional extra configuration properties)
.buildApi(TheApi.class); // or buildView(Abstraction.class)
In the your case, you want to build the SQS api, and since that API is
not yet supported in a "portable abstraction" such as the
ComputeService or the BlobStore, you can create it with the "buildApi"
method. Something like:
SQSApi sqs = ContextBuilder.newBuilder("aws-sqs")
.credentials("access key", "secret key")
.buildApi(SQSApi.class);
You can read a quick intro to the basic jclouds concepts here [2].
HTH!
I.
[1] http://jclouds.apache.org/reference/javadoc/1.9.x/org/jclouds/ContextBuilder.html
[2] http://jclouds.apache.org/start/concepts/
On 9 November 2015 at 20:53, Mirabito, Massimo (Max) (CDC/OID/NCHHSTP)
(CTR) <mc...@cdc.gov> wrote:
> All,
>
>
>
> I just started using JCloud for the past several days. I am having
> difficulty in finding a working example that connects JCloud to AWS-SQS.
> Could anyone point me in the right direction or share snippet of code?.
>
>
>
> Thanks in advance for any help
>
>
>
> max
RE: Help on how to use JCloud API with SQS
Posted by "Mirabito, Massimo (Max) (CDC/OID/NCHHSTP) (CTR)" <mc...@cdc.gov>.
Thanks for the clarification. I just opened a Jira improvement
Thanks,
max
-----Original Message-----
From: Ignasi Barrera [mailto:nacx@apache.org]
Sent: Tuesday, November 10, 2015 07:19
To: user@jclouds.apache.org
Subject: Re: Help on how to use JCloud API with SQS
Unfortunately I think MessagAttributes are not yet supported in jclouds. Mind opening a JIRA issue [1] so we can properly track this?
I.
[1] https://issues.apache.org/jira/browse/JCLOUDS
On 10 November 2015 at 13:05, Mirabito, Massimo (Max)
(CDC/OID/NCHHSTP) (CTR) <mc...@cdc.gov> wrote:
> Hi Ignasi,
>
> Thank you this is helpful and I am able to send a simple message but something is still not clicking even after reading the API docs.
>
> For example in AWS I can include message attributes when I send a
> message like this
>
> AWSCredentials credentials = Aws.getAwsCredentials(accessKey, secretKey);
> AmazonSQSClient sqs = new AmazonSQSClient(credentials);
> sqs.setRegion(Region.getRegion(Regions.US_EAST_1));
> SendMessageRequest smr = new SendMessageRequest();
> smr.withQueueUrl(url);
> smr.setMessageBody(messageBody);
> for (Map.Entry<String, String> entry : map.entrySet()) {
> System.out.println(entry.getKey() + " :: " + entry.getValue());
> MessageAttributeValue mav = new MessageAttributeValue();
> mav.setStringValue(entry.getValue());
> mav.setDataType("String");
> smr.addMessageAttributesEntry(entry.getKey(), mav);
> }
> SendMessageResult x = sqs.sendMessage(smr);
> System.out.println("SQS message published..." + x.getMessageId());
> }
>
> I cannot understand which API or object I would use in Jcloud to do
> the same I thought using the SendMessageOptions would work but it's
> not
>
> Thanks again
> max
>
>
> -----Original Message-----
> From: Ignasi Barrera [mailto:nacx@apache.org]
> Sent: Monday, November 09, 2015 15:49
> To: user@jclouds.apache.org
> Subject: Re: Help on how to use JCloud API with SQS
>
> Hi Max,
>
> I haven't used that API, but in jclouds all APIs and providers are instantiated the same way. You need to use the ContextBuilder [1] to configure the provider, the credentials, and configuration properties that may be required for some particular providers. In general, it looks like:
>
> TheApi api = ContextBuilder.newBuilder("api or provider id")
> .credentials("identity", "credential")
> .overrides(optional extra configuration properties)
> .buildApi(TheApi.class); // or buildView(Abstraction.class)
>
> In the your case, you want to build the SQS api, and since that API is not yet supported in a "portable abstraction" such as the ComputeService or the BlobStore, you can create it with the "buildApi"
> method. Something like:
>
> SQSApi sqs = ContextBuilder.newBuilder("aws-sqs")
> .credentials("access key", "secret key")
> .buildApi(SQSApi.class);
>
> You can read a quick intro to the basic jclouds concepts here [2].
>
> HTH!
>
> I.
>
>
> [1]
> http://jclouds.apache.org/reference/javadoc/1.9.x/org/jclouds/ContextB
> uilder.html [2] http://jclouds.apache.org/start/concepts/
>
> On 9 November 2015 at 20:53, Mirabito, Massimo (Max) (CDC/OID/NCHHSTP)
> (CTR) <mc...@cdc.gov> wrote:
>> All,
>>
>>
>>
>> I just started using JCloud for the past several days. I am having
>> difficulty in finding a working example that connects JCloud to AWS-SQS.
>> Could anyone point me in the right direction or share snippet of code?.
>>
>>
>>
>> Thanks in advance for any help
>>
>>
>>
>> max
Re: Help on how to use JCloud API with SQS
Posted by Ignasi Barrera <na...@apache.org>.
Unfortunately I think MessagAttributes are not yet supported in
jclouds. Mind opening a JIRA issue [1] so we can properly track this?
I.
[1] https://issues.apache.org/jira/browse/JCLOUDS
On 10 November 2015 at 13:05, Mirabito, Massimo (Max)
(CDC/OID/NCHHSTP) (CTR) <mc...@cdc.gov> wrote:
> Hi Ignasi,
>
> Thank you this is helpful and I am able to send a simple message but something is still not clicking even after reading the API docs.
>
> For example in AWS I can include message attributes when I send a message like this
>
> AWSCredentials credentials = Aws.getAwsCredentials(accessKey, secretKey);
> AmazonSQSClient sqs = new AmazonSQSClient(credentials);
> sqs.setRegion(Region.getRegion(Regions.US_EAST_1));
> SendMessageRequest smr = new SendMessageRequest();
> smr.withQueueUrl(url);
> smr.setMessageBody(messageBody);
> for (Map.Entry<String, String> entry : map.entrySet()) {
> System.out.println(entry.getKey() + " :: " + entry.getValue());
> MessageAttributeValue mav = new MessageAttributeValue();
> mav.setStringValue(entry.getValue());
> mav.setDataType("String");
> smr.addMessageAttributesEntry(entry.getKey(), mav);
> }
> SendMessageResult x = sqs.sendMessage(smr);
> System.out.println("SQS message published..." + x.getMessageId());
> }
>
> I cannot understand which API or object I would use in Jcloud to do the same I thought using the SendMessageOptions would work but it's not
>
> Thanks again
> max
>
>
> -----Original Message-----
> From: Ignasi Barrera [mailto:nacx@apache.org]
> Sent: Monday, November 09, 2015 15:49
> To: user@jclouds.apache.org
> Subject: Re: Help on how to use JCloud API with SQS
>
> Hi Max,
>
> I haven't used that API, but in jclouds all APIs and providers are instantiated the same way. You need to use the ContextBuilder [1] to configure the provider, the credentials, and configuration properties that may be required for some particular providers. In general, it looks like:
>
> TheApi api = ContextBuilder.newBuilder("api or provider id")
> .credentials("identity", "credential")
> .overrides(optional extra configuration properties)
> .buildApi(TheApi.class); // or buildView(Abstraction.class)
>
> In the your case, you want to build the SQS api, and since that API is not yet supported in a "portable abstraction" such as the ComputeService or the BlobStore, you can create it with the "buildApi"
> method. Something like:
>
> SQSApi sqs = ContextBuilder.newBuilder("aws-sqs")
> .credentials("access key", "secret key")
> .buildApi(SQSApi.class);
>
> You can read a quick intro to the basic jclouds concepts here [2].
>
> HTH!
>
> I.
>
>
> [1] http://jclouds.apache.org/reference/javadoc/1.9.x/org/jclouds/ContextBuilder.html
> [2] http://jclouds.apache.org/start/concepts/
>
> On 9 November 2015 at 20:53, Mirabito, Massimo (Max) (CDC/OID/NCHHSTP)
> (CTR) <mc...@cdc.gov> wrote:
>> All,
>>
>>
>>
>> I just started using JCloud for the past several days. I am having
>> difficulty in finding a working example that connects JCloud to AWS-SQS.
>> Could anyone point me in the right direction or share snippet of code?.
>>
>>
>>
>> Thanks in advance for any help
>>
>>
>>
>> max
RE: Help on how to use JCloud API with SQS
Posted by "Mirabito, Massimo (Max) (CDC/OID/NCHHSTP) (CTR)" <mc...@cdc.gov>.
Hi Ignasi,
Thank you this is helpful and I am able to send a simple message but something is still not clicking even after reading the API docs.
For example in AWS I can include message attributes when I send a message like this
AWSCredentials credentials = Aws.getAwsCredentials(accessKey, secretKey);
AmazonSQSClient sqs = new AmazonSQSClient(credentials);
sqs.setRegion(Region.getRegion(Regions.US_EAST_1));
SendMessageRequest smr = new SendMessageRequest();
smr.withQueueUrl(url);
smr.setMessageBody(messageBody);
for (Map.Entry<String, String> entry : map.entrySet()) {
System.out.println(entry.getKey() + " :: " + entry.getValue());
MessageAttributeValue mav = new MessageAttributeValue();
mav.setStringValue(entry.getValue());
mav.setDataType("String");
smr.addMessageAttributesEntry(entry.getKey(), mav);
}
SendMessageResult x = sqs.sendMessage(smr);
System.out.println("SQS message published..." + x.getMessageId());
}
I cannot understand which API or object I would use in Jcloud to do the same I thought using the SendMessageOptions would work but it's not
Thanks again
max
-----Original Message-----
From: Ignasi Barrera [mailto:nacx@apache.org]
Sent: Monday, November 09, 2015 15:49
To: user@jclouds.apache.org
Subject: Re: Help on how to use JCloud API with SQS
Hi Max,
I haven't used that API, but in jclouds all APIs and providers are instantiated the same way. You need to use the ContextBuilder [1] to configure the provider, the credentials, and configuration properties that may be required for some particular providers. In general, it looks like:
TheApi api = ContextBuilder.newBuilder("api or provider id")
.credentials("identity", "credential")
.overrides(optional extra configuration properties)
.buildApi(TheApi.class); // or buildView(Abstraction.class)
In the your case, you want to build the SQS api, and since that API is not yet supported in a "portable abstraction" such as the ComputeService or the BlobStore, you can create it with the "buildApi"
method. Something like:
SQSApi sqs = ContextBuilder.newBuilder("aws-sqs")
.credentials("access key", "secret key")
.buildApi(SQSApi.class);
You can read a quick intro to the basic jclouds concepts here [2].
HTH!
I.
[1] http://jclouds.apache.org/reference/javadoc/1.9.x/org/jclouds/ContextBuilder.html
[2] http://jclouds.apache.org/start/concepts/
On 9 November 2015 at 20:53, Mirabito, Massimo (Max) (CDC/OID/NCHHSTP)
(CTR) <mc...@cdc.gov> wrote:
> All,
>
>
>
> I just started using JCloud for the past several days. I am having
> difficulty in finding a working example that connects JCloud to AWS-SQS.
> Could anyone point me in the right direction or share snippet of code?.
>
>
>
> Thanks in advance for any help
>
>
>
> max