Why does basicReject does not work with Apache Qpid? - spring

I'm using qpid-broker for integration testing my spring-boot-start-amqp application which uses basicGet (autoAck=false), basicAck and basicReject for handling the messages. basicReject (with requeue=false) works fine with my external rabbitmq instance but doesn't work with the qpid-broker.
I have tested my code with an external RabbitMQ instance where everything works fine but with the embedded Apache Qpid server the test fails because basicReject is not working properly.
Getting the message and rejecting it:
rabbitTemplate.execute {
val response = it.basicGet(config.queueName, false)
it.basicReject(response.envelope.deliveryTag, false)
}
Check if the message is still in the queue:
rabbitTemplate.execute {
val response = it.basicGet(config.queueName, false)
Assertions.assertThat(response).isNull()
}
My Qpid config:
{
"name": "EmbeddedBroker",
"modelVersion": "7.0",
"authenticationproviders": [
{
"name": "password",
"type": "Plain",
"secureOnlyMechanisms": [],
"users": [
{
"name": "guest",
"password": "guest",
"type": "managed"
}
]
}
],
"ports": [
{
"name": "AMQP",
"port": "${qpid.amqp_port}",
"protocols": [ "AMQP_0_9_1" ],
"authenticationProvider": "password",
"virtualhostaliases": [
{
"name": "defaultAlias",
"type": "defaultAlias"
}
]
}
],
"virtualhostnodes": [
{
"name": "default",
"defaultVirtualHostNode": "true",
"type": "Memory",
"virtualHostInitialConfiguration": "{\"type\": \"Memory\" }"
}
]
}
Why does basicReject work fine with my RabbitMQ instance but doesn't work properly with the Apache Qpid embedded broker?
Edit: My solution was to move away from qpid and use a RabbitMQ Testcontainer.

Related

Only enable TLS.1.3 in Web-Api hosting in Kestrel-Service

We are currently developing an ASP NET Core Web API hosted in a Kestrel Windows service. We want to enable TLS 1.3 only and disable all other SSL protocols.
The following code works. TLS1.2 and TLS1.3 are both enabled.
{
"Kestrel": {
"Endpoints": {
"HttpsForDeveloper": {
"Url": "https://localhost:5001",
"SslProtocols": ["Tls12", "Tls13"]
}
},
"Certificates": {
"Default": {
"Subject": "localhost",
"Store": "My",
"Location": "LocalMachine",
"AllowInvalid": true
}
}
}
}
But if I change the code block to remove TLS1.2. Is the page no longer available.
{
"Kestrel": {
"Endpoints": {
"HttpsForDeveloper": {
"Url": "https://localhost:5001",
"SslProtocols": ["Tls13"]
}
},
"Certificates": {
"Default": {
"Subject": "localhost",
"Store": "My",
"Location": "LocalMachine",
"AllowInvalid": true
}
}
}
}
In Postman I get the following error:
Does anyone have any tips for me or know what I'm doing wrong?
The problem was the lack of support for TLS 1.3 in the Windows versions we used. I was able to solve the problem with the following article.
https://stackoverflow.com/a/59210166/6092585

How to change the local payload when invoking a lambda in cloud9 IDE?

I'm developing in AWS Cloud9, and have a basic "Hello, World" API set up using Lambda.
Now I would like to iterate so that the API can accept parameters. Cloud9 used to have a convenient UI for modifying the payload when running "local" (in the IDE, without deploy). But I can't find where this has been moved, and the documentation still references the previous UI.
To test this, I've included a simple print(event) in my Lambda, and started modifying various components. So far I only print an empty dict ({}).
I suspect it's in the launch.json but so far everything I've modified has not been picked up. Showing below
{
"configurations": [
{
"type": "aws-sam",
"request": "direct-invoke",
"name": "API token-to-geojson:HelloWorldFunction (python3.9)",
"invokeTarget": {
"target": "api",
"templatePath": "token-to-geojson/template.yaml",
"logicalId": "HelloWorldFunction"
},
"api": {
"path": "/hello",
"httpMethod": "get",
"payload": {
"json": {}
}
},
"lambda": {
"runtime": "python3.9"
}
},
{
"type": "aws-sam",
"request": "direct-invoke",
"name": "token-to-geojson:HelloWorldFunction (python3.9)",
"invokeTarget": {
"target": "template",
"templatePath": "token-to-geojson/template.yaml",
"logicalId": "HelloWorldFunction"
},
"lambda": {
"payload": {
"ticky": "tacky"
},
"environmentVariables": {},
"runtime": "python3.9"
}
}
]
}
The only thing I saw is we need to add "json" before the actual json data. In the example below, it appears the IDE already knows the id is event.id (note event is the first argument of the handler).
"lambda": {
"payload": {
"json": {
"id": 1001
}
},
"environmentVariables": {}
}

Missing property sources in Spring Cloud Config Server with S3 Backend

We are trying to migrate our Spring Cloud Config Server from a Git Backend to S3.
With git when we want to get config for the service my-service and profile development we hit
https://my-config-server/my-service/development
and this returns something like
{
"name": "my-service",
"profiles": [
"development"
],
"label": null,
"version": "fgdfgdfg",
"state": null,
"propertySources": [
{
"name": "https://bitbucket.org/company/config-repo.git/my-service-development.yml",
"source": {
[properties]
}
},
{
"name": "https://bitbucket.org/company/config-repo.git/application-development.yml",
"source": {
[properties]
}
},
{
"name": "https://bitbucket.org/company/config-repo.git/my-service.yml",
"source": {
[properties]
}
},
{
"name": "https://bitbucket.org/company/config-repo.git/application.yml",
"source": {
[properties]
}
}
]
}
And we have the files my-service-development.yml, application-development.yml, my-service.yml and application.yml so that properties in the more specific ones override properties in the more general ones.
Eg we can set a property in my-service.yml but override it for the development environment in my-service-development.yml. Likewise we can set common properties for an environment (such as database connections or messaging connections in application-development.yml.
However when we switch to S3 and hit the same URL we only get
{
"name": "my-service",
"profiles": [
"development"
],
"label": null,
"version": "twtwert",
"state": null,
"propertySources": [
{
"name": "s3:my-service-development",
"source": {
[properties]
}
}
]
}
ie we only get the most specific property source and not the others.
Is there something we are missing or is this a bug in the S3 implementation?
We are using spring boot 2.5.4, spring cloud 2020.0.3 and spring-cloud-aws 2.3.2

Alexa.Discovery response: no device detected by Alexa

I am implementing my Alexa Home Skill using AWS Lambda.
Given the following request I receive when I try to detect new devices on Alexa Skil test page:
{directive={header={namespace=Alexa.Discovery, name=Discover, payloadVersion=3, messageId=0160c7e7-031f-47ee-a1d9-a23f38f87a9e}, payload={scope={type=BearerToken, token=...}}}}
I respond with the following:
{
"event": {
"payload": {
"endpoints": [
{
"displayCategories": [
"SMARTPLUG"
],
"capabilities": [
{
"type": "AlexaInterface",
"interface": "Alexa",
"version": "3"
},
{
"type": "AlexaInterface",
"interface": "Alexa.PowerController",
"version": "3",
"properties": {
"retrievable": true,
"supported": [
{
"name": "powerState"
}
],
"proactivelyReported": true
}
},
{
"type": "AlexaInterface",
"interface": "Alexa.EndpointHealth",
"version": "3",
"properties": {
"retrievable": true,
"supported": [
{
"name": "connectivity"
}
],
"proactivelyReported": true
}
}
],
"manufacturerName": "mirko.io",
"endpointId": "ca84ef6d-53b1-430a-8a5e-a62f174eac5e",
"description": "mirko.io forno (id: ca84ef6d-53b1-430a-8a5e-a62f174eac5e)",
"friendlyName": "forno"
}
]
},
"header": {
"payloadVersion": "3",
"namespace": "Alexa.Discovery",
"name": "Discover.Response",
"messageId": "c0555cc8-ad7a-4377-b310-9de9b9ab6282"
}
}
}
Despite that, for some reasons Alexa answers that it did not find any new device.
I may be mistaken but I am pretty sure it used to work before I decided to add the Alexa.EndpointHealth interface.
Your response object looks right to me, except the extra "endpoint" field.
"endpoint": {
"endpointId": "INVALID",
"scope": {
"type": "BearerToken",
"token": "INVALID"
}
}
There's no such field in the Alexa.Discovery documentation. Try removing it and see if it resolves the issue.

How to configure Spring Actuator for httptrace and Rest Template?

I have a Spring boot application that it executes several parallel requests, of course, using RestTemplate class.
I configured Spring actuator,to see the Http Trace.
management.endpoints.web.exposure.include=httptrace
When I execute: http://localhost:8080/actuator/httptrace
I see information but related to the request I am doing to my Spring Mvc exposed controllers, but I don't see any info related to the request I am doing internally.
So how can I achieve that? Could you show me some example?
Thanks in advance folks!
You can use Spring Boot /actuator/metrics/http.server.requests to get all endPoints which are executed with their count, exception, outcome, status, total time, etc as follow.
If you want to see details for particular endPoint then you can do it by calling request as follow
localhost:8889/actuator/metrics/http.server.requests?tag=uri:<endPoint>
localhost:8889/actuator/metrics/http.server.requests?tag=uri:/user/asset/getAllAssets
localhost:8889/actuator/metrics/http.server.requests?tag=uri:/user/asset/getAllAssets&tag=status:200
You will get COUNT as how many times particular endPoint has been
called
You will get COUNT as how many times particular endPoint has been
called with a particular Status
To get the average time to execute endPoint you can do
TOTAL_TIME/COUNT for particular endPoint as well as for the whole
application
More Details are Here
localhost:8889/actuator/metrics/http.server.requests
{
"name": "http.server.requests",
"description": null,
"baseUnit": "seconds",
"measurements": [
{
"statistic": "COUNT",
"value": 3
},
{
"statistic": "TOTAL_TIME",
"value": 0.21817219999999998
},
{
"statistic": "MAX",
"value": 0.1379249
}
],
"availableTags": [
{
"tag": "exception",
"values": [
"MethodArgumentTypeMismatchException",
"None"
]
},
{
"tag": "method",
"values": [
"GET"
]
},
{
"tag": "uri",
"values": [
"/{id}.*",
"/user/asset/getAsset/{assetId}",
"/user/asset/getAllAssets"
]
},
{
"tag": "outcome",
"values": [
"CLIENT_ERROR",
"SUCCESS"
]
},
{
"tag": "status",
"values": [
"400",
"404",
"200"
]
}
]
}

Resources