question stringlengths 11 28.2k | answer stringlengths 26 27.7k | tag stringclasses 130
values | question_id int64 935 78.4M | score int64 10 5.49k |
|---|---|---|---|---|
I want to use AWS CDK to define an API Gateway and a lambda that the APIG will proxy to.
The OpenAPI spec supports a x-amazon-apigateway-integration custom extension to the Swagger spec (detailed here), for which an invocation URL of the lambda is required. If the lambda is defined in the same stack as the API, I don't... | There is an existing workaround. Here is how:
Your OpenAPI file has to look like this:
openapi: "3.0.1"
info:
title: "The Super API"
description: "API to do super things"
version: "2019-09-09T12:56:55Z"
servers:
- url: ""
variables:
basePath:
default:
Fn::Sub: ${ApiStage}
paths:
/path/subp... | OpenAPI | 62,179,893 | 25 |
I'm trying to add an object in an array, but this seems not be possible. I've tried the following, but I get always the error:
Property Name is not allowed.
This is shown for all items defined in the devices array. How can I define items in an array in OpenAPI?
/demo/:
post:
summary: Summary
request... | You need to add two extra lines inside items to specify that the item type is an object:
devices:
type: array
items:
type: object # <----------
properties: # <----------
Name:
type: string
... | OpenAPI | 63,738,715 | 25 |
I am using Dotnet Core healthchecks as described here. In short, it looks like this:
First, you configure services like this:
services.AddHealthChecks()
.AddSqlServer("connectionString", name: "SQlServerHealthCheck")
... // Add multiple other checks
Then, you register an endpoint like this:
app.UseHealthChecks... | I used this approach and it worked well for me: https://www.codit.eu/blog/documenting-asp-net-core-health-checks-with-openapi
Add a new controller e.g. HealthController and inject the HealthCheckService into the constructor. The HealthCheckService is added as a dependency when you call AddHealthChecks in Startup.cs:
Th... | OpenAPI | 54,362,223 | 24 |
I have the following SecurityScheme definition using springdoc-openapi for java SpringBoot RESTful app:
@Bean
public OpenAPI customOpenAPI() {
return new OpenAPI()
.components(new Components().addSecuritySchemes("bearer-jwt",
new SecurityScheme().type(SecurityScheme.Type... | Yes, you can do it in the same place calling addSecurityItem:
@Bean
public OpenAPI customOpenAPI() {
return new OpenAPI()
.components(new Components().addSecuritySchemes("bearer-jwt",
new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("bearer").bearerFormat("JWT")
... | OpenAPI | 59,357,205 | 24 |
Spring Boot 2.2 application with springdoc-openapi-ui (Swagger UI) runs HTTP port.
The application is deployed to Kubernetes with Ingress routing HTTPS requests from outside the cluster to the service.
In this case Swagger UI available at https://example.com/api/swagger-ui.html has wrong "Generated server url" - http:/... | I had same problem. Below worked for me.
@OpenAPIDefinition(
servers = {
@Server(url = "/", description = "Default Server URL")
}
)
@SpringBootApplication
public class App {
// ...
}
| OpenAPI | 60,625,494 | 24 |
One of my endpoints returns a JSON (not huge, around 2MB). Trying to run GET on this endpoint in swagger-ui results in the browser hanging for a few minutes. After this time, it finally displays the JSON.
Is there a way to define that the response shouldn't be rendered but provided as a file to download instead?
I'm us... | Lex45x proposes in this github issue to disable syntax highlighting. In ASP.Net Core you can do this with
app.UseSwaggerUI(config =>
{
config.ConfigObject.AdditionalItems["syntaxHighlight"] = new Dictionary<string, object>
{
["activated"] = false
};
});
This significantly improves render performanc... | OpenAPI | 63,615,230 | 24 |
I'm having trouble defining a reusable schema component using OpenAPI 3 which would allow for an array that contains multiple types. Each item type inherits from the same parent class but has specific child properties. This seems to work alright in the model view on SwaggerHub but the example view doesn't show the data... | Your spec is correct. It's just that example rendering for oneOf and anyOf schemas is not yet supported in Swagger UI. You can track this issue for status updates:
Multiple responses using oneOf attribute do not appear in UI
The workaround is to manually add an example alongside the oneOf/anyOf schema or to the parent ... | OpenAPI | 47,656,791 | 23 |
Here it says I could refer to the definition in another file for an individual path, but the example seems to refer to a whole file, instead of a single path definition under the paths object. How to assign an individual path in another file's paths object?
For example, I have Anotherfile.yaml that contains the /a/b pa... | When referencing paths, you need to escape the path name by replacing / with ~1, so that /a/b becomes ~1a~1b. Note that you escape just the path name and not the #/paths/ prefix.
$ref: 'Anotherfile.yaml#/paths/~1a~1b'
| OpenAPI | 58,909,124 | 23 |
Is it possible to group multiple parameters to reference them in multiple routes?
For example I have a combination of parameters which I need in every route. They are defined as global parameters. How can I group them?
I think about a definition like this:
parameters:
MetaDataParameters:
# Meta Data Properties
... | This is not possible with Swagger 2.0, OpenAPI 3.0 or 3.1. I've opened a feature request for this and it is proposed for a future version:
https://github.com/OAI/OpenAPI-Specification/issues/445
| OpenAPI | 32,091,430 | 22 |
I am starting a REST service, using Swagger Codegen. I need to have different responses for different parameters.
Example: <baseURL>/path can use ?filter1= or ?filter2=, and these parameters should produce different response messages.
I want my OpenAPI YAML file to document these two query params separately. Is this po... | It is not supported in the 2.0 spec, and not in 3.x either.
Here are the corresponding proposals in the OpenAPI Specification repository:
Accommodate legacy APIs by allowing query parameters in the path
Querystring in Path Specification
| OpenAPI | 40,495,880 | 22 |
I'm using the online Swagger Editor to create a Swagger spec for my API.
My API has a single GET request endpoint, and I'm using the following YAML code to describe the input parameters:
paths:
/fooBar:
get:
tags:
- foobar
summary: ''
description: ''
operationId: foobar
consu... | OpenAPI 2.0
OpenAPI/Swagger 2.0 does not have the example keyword for non-body parameters. You can specify examples in the parameter description. Some tools like Swagger UI v2, v3.12+ and Dredd also support the x-example extension property for this purpose:
parameters:
- name: address
in: query
... | OpenAPI | 43,933,516 | 22 |
I have the following OpenAPI definition:
swagger: "2.0"
info:
version: 1.0.0
title: Simple API
description: A simple API to learn how to write OpenAPI Specification
schemes:
- https
host: now.httpbin.org
paths:
/:
get:
summary: Get date in rfc2822 format
responses:
200:
sch... |
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8081' is therefore not allowed access.
This is a CORS issue. The server at https://now.httpbin.org does not support CORS, so the browsers won't let web pages served from other domains to make requests to now.httpbin... | OpenAPI | 51,407,341 | 22 |
I'm creating a V2 Function App and want to use Swagger/Open API for docs, however it is not yet supported in the Azure Portal for V2 Functions.
Any suggestions on how I can use Swagger with V2 Functions in VSTS to create the docs on each build?
| TL;DR - Use the NuGet package to render Open API document and Swagger UI through Azure Functions.
UPDATE (2021-06-04)
Microsoft recently announced the OpenAPI support on Azure Functions during the //Build event.
The Aliencube extension has now been archived and no longer supported. Please use this official extension.
... | OpenAPI | 52,500,329 | 22 |
type": "array",
"items": {
"type": "string",
"enum": ["MALE","FEMALE","WORKER"]
}
or
type": "array",
"items": {
"type": "string",
},
"enum": ["MALE","FEMALE","WORKER"]
?
Nothing in the spec about this. The goal is of course to get swagger-ui to show the enum values.
| It will depend on what you want to enum:
Each enum value MUST be of the described object type
in first case a String
in second one an Array of String
First syntax means These are the possible values of the String in this array
AnArray:
type: array
items:
type: string
enum:
- MALE
- FEMALE
... | OpenAPI | 36,888,626 | 21 |
I have an API which allows any arbitrary path to be passed in, for example all of these:
/api/tags
/api/tags/foo
/api/tags/foo/bar/baz
Are valid paths. I tried to describe it as follows:
/tags{tag_path}:
get:
parameters:
- name: tag_path
in: path
required: true
type: s... | This is not supported as of OpenAPI 3.1, and I have to resort to a workaround.
If I have a path /tags{tag_path} and I enter something like this as tag_path: /foo/bar, then the actual query request URL will be: /tags%2Ffoo%2Fbar. So, I just added support for that on my backend: the endpoint handler for /tags* urldecodes... | OpenAPI | 42,335,178 | 21 |
I couldn't find any resources on the use case differences between JSON:API & OpenAPI
From my understanding, JSON:API is more focused on the business data while OpenAPI is more about REST itself?
Any pointers would be great, thanks!
| You can use OpenAPI to describe API's, and JSON:API is a standard to structure your apis. If you use JSON:API, you can still use OpenAPI to describe it.
So OpenAPI's goal is really to provide a full description on how your API can be called, and what operations are available. JSON:API gives you a strong opinion on how ... | OpenAPI | 64,828,587 | 21 |
I am using OpenAPI generator maven plugin like one below for generating Java client code for models .
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.3.1</version>
<executions>
<execution>
<goals>
<goal>g... | To complete this very old thread: Now it does support Lombok annotations.
Example taken from here
<configOptions>
<additionalModelTypeAnnotations>@lombok.Builder @lombok.NoArgsConstructor @lombok.AllArgsConstructor</additionalModelTypeAnnotations>
</configOptions>
| OpenAPI | 65,733,938 | 21 |
The API for which I'm writing a Swagger 2.0 specification is basically a store for any JSON value.
I want a path to read value and a path to store any JSON values (null, number, integer, string, object, array) of non-predefined depth.
Unfortunately, it seems that Swagger 2.0 is quite strict on schemas for input and out... | An arbitrary-type schema can be defined using an empty schema {}:
# swagger: '2.0'
definitions:
AnyValue: {}
# openapi: 3.0.0
components:
schemas:
AnyValue: {}
or if you want a description:
# swagger: '2.0'
definitions:
AnyValue:
description: 'Can be anything: string, number, array, object, etc. (except... | OpenAPI | 32,841,298 | 20 |
I am defining common schemas for Web services and I want to import them in the components/schema section of the specification.
I want to create a canonical data model that is common across multiple services to avoid redefining similar objects in each service definition.
Is there a way to do this?
Is there a similar mec... | You can $ref external OpenAPI schema objects directly using absolute or relative URLs:
responses:
'200':
description: OK
schema:
$ref: './common/Pet.yaml'
# or
# $ref: 'https://api.example.com/schemas/Pet.yaml'
where Pet.yaml contains, for example:
type: object
properties:
id:
type: i... | OpenAPI | 50,179,541 | 20 |
How to enable "Authorize" button in springdoc-openapi-ui (OpenAPI 3.0 /swagger-ui.html) for Basic Authentication.
What annotations have to be added to Spring @Controller and @Configuration classes?
| Define a global security scheme for OpenAPI 3.0 using annotation @io.swagger.v3.oas.annotations.security.SecurityScheme in a @Configuration bean:
@Configuration
@OpenAPIDefinition(info = @Info(title = "My API", version = "v1"))
@SecurityScheme(
name = "basicAuth",
type = SecuritySchemeType.HTTP,
scheme = "b... | OpenAPI | 59,898,740 | 20 |
I'm migrating my API from Swagger 2.0 to OpenAPI 3.0. In a DTO I have a field specified as a byte array.
Swagger definition of the DTO:
Job:
type: object
properties:
body:
type: string
format: binary
Using the definition above the swagger code generator generates an object that accepts b... | You must set type: string and format: byte
Original answer: when using swagger codegen getting 'List<byte[]>' instead of simply 'byte[]'
| OpenAPI | 62,794,949 | 20 |
Having a hard time configuring Swagger UI
Here are the very explanatory docs: https://django-rest-swagger.readthedocs.io/en/latest/
YAML docstrings are deprecated. Does somebody know how to configure Swagger UI from within the python code? or what file should I change to group api endpoints, to add comments to each end... | This is how I managed to do it:
base urls.py
urlpatterns = [
...
url(r'^api/', include('api.urls', namespace='api')),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
...
]
api.urls.py
urlpatterns = [
url(r'^$', schema_view, name='swagger'),
url(r'^article/(?P<pk>[0-9]+)/$',
Article... | OpenAPI | 38,542,690 | 19 |
I am looking to represent the following JSON Object in OpenAPI:
{
"name": "Bob",
"age": 4,
...
}
The number of properties and the property names are not fully predetermined, so I look to use additionalProperties. However, I'm not too certain how it would be represented through OpenAPI/Swagger 2.0. I tried this:
... | OpenAPI 3.1
In OpenAPI 3.1, the type keyword can take a list of types:
Person:
type: object
additionalProperties:
type: [string, integer]
OpenAPI 3.x
OpenAPI 3.0+ supports oneOf so you can use:
Person:
type: object
additionalProperties:
oneOf:
- type: string
- type: integer
OpenAPI 2.0
Ope... | OpenAPI | 46,472,543 | 19 |
I have this schema defined:
User:
type: object
required:
- id
- username
properties:
id:
type: integer
format: int32
readOnly: true
xml:
attribute: true
description: The user ID
username:
type: string
readOnly: true
description: The username
... | An array of User objects is defined as follows:
UserArray:
type: array
items:
$ref: '#/components/schemas/User'
| OpenAPI | 49,827,240 | 19 |
Im trying to generate swagger document for my existing Flask app, I tried with Flask-RESTPlus initially and found out the project is abundant now and checked at the forked project flask-restx https://github.com/python-restx/flask-restx but still i dont think they support openapi 3.0
Im a bit confused to choose the pac... | I found a package to generate openapi 3.0 document
https://apispec.readthedocs.io/en/latest/install.html
This package serves the purpose neatly. Find the below code for detailed usage.
from apispec import APISpec
from apispec.ext.marshmallow import MarshmallowPlugin
from apispec_webframeworks.flask import FlaskPlugin
f... | OpenAPI | 62,066,474 | 19 |
I am using SpringDoc 1.4.3 for swagger. I have added the below configuration to disabled the petstore URLs in application.yml
Configuration
springdoc:
swagger-ui:
disable-swagger-default-url: true
tags-sorter: alpha
operations-sorter: alpha
doc-expansion: none
but when I hit the https://petstore.swag... | Already tested and validated thanks to the following feature support:
https://github.com/springdoc/springdoc-openapi/issues/714
Just use, the following property:
springdoc.swagger-ui.disable-swagger-default-url=true
| OpenAPI | 63,152,653 | 19 |
Below is my fastAPI code
from typing import Optional, Set
from fastapi import FastAPI
from pydantic import BaseModel, HttpUrl, Field
from enum import Enum
app = FastAPI()
class Status(Enum):
RECEIVED = 'RECEIVED'
CREATED = 'CREATED'
CREATE_ERROR = 'CREATE_ERROR'
class Item(BaseModel):
name: str
... | create the Status class by inheriting from both str and Enum
class Status(str, Enum):
RECEIVED = 'RECEIVED'
CREATED = 'CREATED'
CREATE_ERROR = 'CREATE_ERROR'
References
Working with Python enumerations--(FastAPI doc)
[BUG] docs don't show nested enum attribute for body--(Issue #329)
| OpenAPI | 64,160,594 | 19 |
When i generate code for Spring from my swagger yaml , usually controller layer is generated using delegate pattern , such that for a single model three files are generated . For example , if i defined a model named Person in my swagger/open API yaml file , three files get generated as :
PersonApi (interface that... | First of all a clarification: as already mentioned in a comment, you are not forced to use the delegation. On the contrary, the default behavior of the Spring generator is to not use the delegation pattern, as you can easily check in the docs. In this case it will generate only the PersonApi interface and PersonApiCont... | OpenAPI | 66,294,655 | 19 |
I want almost all my paths to have the following 3 generic error responses. How do I describe that in Swagger without copypasting these lines everywhere?
401:
description: The requester is unauthorized.
schema:
$ref: '#/definitions/Error'
500:
description: "Something went wrong. It's s... | OpenAPI 2.0 (fka Swagger 2.0)
Looks like I can add the following global response definition:
# An object to hold responses that can be used across operations.
# This property does not define global responses for all operations.
responses:
NotAuthorized:
description: The requester is unauthorized.
schema:
... | OpenAPI | 35,921,287 | 18 |
I would like to denote decimal with 2 places and decimal with 1 place in my api documentation. I'm using swagger 2.0, Is there inbuilt defined type or any other 'round' parameter in the specs, or my only option is to use 'x-' extension?
| OpenAPI (fka Swagger) Specification uses a subset of JSON Schema to describe the data types.
If the parameter is passed as a number, you can try using multipleOf as suggested in this Q&A:
type: number
multipleOf: 0.1 # up to 1 decimal place, e.g. 4.2
# multipleOf: 0.01 # up to 2 decimal places, e.g. 4.25
Hovewer... | OpenAPI | 44,968,026 | 18 |
Designing an API using editor.swagger.io I find myself unable to add a requestBody attribute, getting an error I cannot address:
Schema error at paths['/projects/{projectId}/user'].post
should NOT have additional properties
additionalProperty: requestBody
Jump to line 91
I don't understand what I'm doing wrong, espec... | I got clarifications from an external source, so here's what I've learned:
Specifying swagger: 2.0 also means that the OpenAPI Specification 2.0.0 is expected by the editor, whereas I thought it used OAS 3.
I'm still unsure about why in: body did not work in the first place but I've added quotes around "body", which ma... | OpenAPI | 47,632,281 | 18 |
I need to describe an api having in request body an object with required fields and one of these fields it's an object itself having another set of required fields.
I'm using open api v3 and swagger editor (https://editor.swagger.io/)
After i put my .yaml file onto the editor I generate an html client (> generate cli... | Solved!
I used components and schemas, but I think this could be a bug, opened an issue on swagger editor repo:
https://github.com/swagger-api/swagger-editor/issues/1952
openapi: 3.0.0
info:
title: Example API
description: Example API specification
version: 0.0.2
servers:
- url: https://example/api
paths... | OpenAPI | 54,803,837 | 18 |
I am writing an app where I need to have two completely different set of response structures depending on logic.
Is there any way to handle this so that I can have two different response models serialized, validated and returned and reflect in OpenAPI JSON?
I am using pydantic to write models.
| Yes this is possible. You can use Union for that in the response_model= parameter in your path decorator (I used the new python 3.10 style below). Here is a full example, this will work as is.
from typing import Union
from fastapi import FastAPI, Query
from pydantic import BaseModel
class responseA(BaseModel):
na... | OpenAPI | 72,919,006 | 18 |
I have a symfony project, where I use api-platform.
I have an entity, and I have data providers for it. I am in trouble with definition of additional parameters for a collection endpoint.
An entity is called suggestion. It has to return collection of documents from elastic search.
An endpoint is:
/suggestion
This endp... | Finally figured it out.
I haven't found a documentation for it yet, but I found a way.
In an entity class Suggestion.php I've added some lines of annotations:
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Grou... | OpenAPI | 50,369,988 | 17 |
I'm writing a Swagger specification for an future public API that requires a very detailed and clean documentation. Is there a way to reference/link/point to another endpoint at some other location in the swagger.yml file?
For example, here is what I am trying to achieve:
paths:
/my/endpoint:
post:
tags:
... | Swagger UI provides permalinks for tags and operations if it's configured with the deepLinking: true option. These permalinks are generated based on the tag names and operationId (or if there are no operationId - based on the endpoint names and HTTP verbs).
index.html#/tagName
index.html#/tagName/operationId
You can u... | OpenAPI | 52,703,804 | 17 |
I have an open API spec with a parameter like this:
- name: platform
in: query
description: "Platform of the application"
required: true
schema:
type: string
enum:
- "desktop"
- "online"
when I get the "platform" parameter from URL , it can be like this :
platform=online or
platform=ONLIN... | Enums are case-sensitive. To have a case-insensitive schema, you can use a regular expression pattern instead:
- name: platform
in: query
description: 'Platform of the application. Possible values: `desktop` or `online` (case-insensitive)'
required: true
schema:
type: string
pattern: '^[Dd][Ee][Ss][Kk][... | OpenAPI | 60,772,786 | 17 |
Is there a way to generate OpenAPI v3 specification from go source code? Let's say I have a go
API like the one below and I'd like to generate the OpenAPI specification (yaml file) from it. Something similar to Python's Flask RESTX. I know there are tools that generate go source code from the specs, however, I'd like t... | You can employ github.com/swaggest/rest to build a self-documenting HTTP REST API. This library establishes a convention to declare handlers in a way that can be used to reflect documentation and schema and maintain a single source of truth about it.
In my personal opinion code first approach has advantages comparing t... | OpenAPI | 66,171,424 | 17 |
I am using Swagger with Scala to document my REST API. I want to enable bulk operations for POST, PUT and DELETE and want the same route to accept either a single object or a collection of objects as body content.
Is there a way to tell Swagger that a param is either a list of values of type A or a single value of type... |
Is there a way to tell Swagger that a param is either a list of values of type A or a single value of type A?
This depends on whether you use OpenAPI 3.0 or OpenAPI (Swagger) 2.0.
OpenAPI uses an extended subset of JSON Schema to describe body payloads. JSON Schema provides the oneOf and anyOf keywords to define mult... | OpenAPI | 31,742,151 | 16 |
I'm writing an Open API 3.0 spec and trying to get response links to render in Swagger UI v 3.18.3.
Example:
openapi: 3.0.0
info:
title: Test
version: '1.0'
tags:
- name: Artifacts
paths:
/artifacts:
post:
tags:
- Artifacts
operationId: createArtifact
requestBody:
content... | Yes this is how Swagger UI currently renders OAS3 links. Rendering of links is one of the things on their OAS3 support backlog:
OAS 3.0 Support Backlog
This is a collection ticket for OAS3 specification features that are not yet supported by Swagger-UI.
...
[ ] Links can't be used to stage another operation
[... | OpenAPI | 55,839,466 | 16 |
How to allow anonymous access to springdoc-openapi-ui (OpenAPI 3.0 /swagger-ui.html) in a Spring Boot application secured by Spring Security?
| To use springdoc-openapi-ui /swagger-ui.html, allow anonymous access to the following endpoints in the WebSecurityConfigurerAdapter using permitAll method:
/v3/api-docs/**
/swagger-ui/**
/swagger-ui.html
Example:
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
pub... | OpenAPI | 59,898,402 | 16 |
I'm using Open API code generator Maven plugin to generate Open API 3.0 from a file. I'm using this plugin in in my pom.xml:
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.3.0</version>
The plugin generates the API without any issues but instead of using Swagger ... | V3 annotations are not supported at this moment.
You need to override mustache templates.
Check these PRs:
https://github.com/OpenAPITools/openapi-generator/pull/4779
https://github.com/OpenAPITools/openapi-generator/pull/6306
more info:
https://github.com/OpenAPITools/openapi-generator/issues/6108
https://github.com/O... | OpenAPI | 62,915,594 | 16 |
I trying to map the following JSON to an OpenAPI 2.0 (Swagger 2.0) YAML definition, and I am not sure how to set mixed array types into my schema:
{
"obj1": [
"string data",
1
]
}
Now, my OpenAPI definition has:
schema:
object1:
type: array
items:
type: string
but this doesn't allow in... | The answer depends on which version of the OpenAPI Specification you use.
OpenAPI 3.1
type can be a list of types, so you can write your schema as:
# openapi: 3.1.0
obj1:
type: array
items:
type: [string, integer]
# or if nulls are allowed:
# type: [string, integer, 'null']
OpenAPI 3.0.x
Mixed types a... | OpenAPI | 38,690,802 | 15 |
By Specification:
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md
A list of tags used by the specification with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the Operation Object must be declared. The tags ... | A couple of examples:
Swagger UI uses tags to group the displayed operations. For example, the Petstore demo has three tags - pet, store and user.
Swagger Codegen uses tags to group endpoints into the same API class file:
For example, an endpoint with the "store" tags will be generated in the StoreApi class file.
... | OpenAPI | 53,517,210 | 15 |
I'm using swagger-jsdoc with Express. Using this lib to describe an api end-point I use following lines in JSDock block in YAML:
/**
* @swagger
* /users:
* post:
* summary: Register a user
* tags: [Users]
* description: Register a new user and return its cookie token (connect.sid)
* parame... | I created a simple extension that targets this particular issue when writing YAML specs with swagger-jsdoc.
Everything is documented in the README, but basically you write your spec like this (which allows for automatic indentation)
/**
* Spec for the route /auth/register.
*
@openapi
/auth/register:
post:
summa... | OpenAPI | 58,186,804 | 15 |
I'm digging here around trying to find a solution, how to merge several OpenApi v3 component definitions in one file.
Let's imagine a situation:
You decided to split your OpenApi into multiple files in different folders. (see image below)
Now you need to combine all your components.v1.yaml into a single schema (i name... | I don't think there is a "native" OpenAPI solution to your problem. People are discussing for a while about OpenAPI overlays/extends/merges. There is currently (2020-04-24) not any consensus about this topic.
Although you could implement your own tool or use an existing one to preprocess your blueprint.v1.yaml and gene... | OpenAPI | 61,262,561 | 15 |
For a legacy API that I document in order for a successful authentication I need to provide the following headers:
X-Access-Token: {token}
Accept: application/json; version=public/v2
For the token part I need document it via:
openapi: 3.0.0
info:
version: "v2"
title: Company App Public Api
description: Integrate... | In OpenAPI 3.0, the request header Accept and the response header Content-Type are both defined as responses.<code>.content.<Accept value>. This needs to be defined in every operation.
paths:
/something:
get:
responses:
'200':
description: Successful operation
content:
... | OpenAPI | 62,593,055 | 15 |
I have a Django project and I am using Django REST framework. I am using drf-spectacular
for OpenAPI representation, but I think my problem is not tied to this package, it's seems a more generic OpenAPI thing to me (but not 100% sure if I am right to this).
Assume that I have a URL structure like this:
urlpatterns = [
... | you are making it harder than it needs to be. In the global settings you can specify a common prefix regex that strips the unwanted parts. that would clean up both operation_id and tags for you. In your case that would probably be:
SPECTACULAR_SETTINGS = {
'SCHEMA_PATH_PREFIX': r'/api/v[0-9]',
}
that should result... | OpenAPI | 62,830,171 | 15 |
Problem
I currently have JWT dependency named jwt which makes sure it passes JWT authentication stage before hitting the endpoint like this:
sample_endpoint.py:
from fastapi import APIRouter, Depends, Request
from JWTBearer import JWTBearer
from jwt import jwks
router = APIRouter()
jwt = JWTBearer(jwks)
@router.get(... | Sorry, got lost with things to do
The endpoint has a unique dependency, call it check from the file check_auth
ENDPOINT
from fastapi import APIRouter, Depends, Request
from check_auth import check
from JWTBearer import JWTBearer
from jwt import jwks
router = APIRouter()
jwt = JWTBearer(jwks)
@router.get("/test_jwt",... | OpenAPI | 64,731,890 | 15 |
I am using Swagger OpenAPI Specification tool. I have a string array property in one of the definitions as follows:
cities:
type: array
items:
type: string
example: "Pune"
My API produces JSON result, so Swagger UI displays the following example for the response:
{
"cities": [
"Pune"
]
}
H... | To display an array example with multiple items, add the example on the array level instead of item level:
cities:
type: array
items:
type: string
example:
- Pune
- Mumbai
- Bangaluru
# or
# example: [Pune, Mumbai, Bangaluru]
In case of array of objects, the example would look like this:
ty... | OpenAPI | 46,578,110 | 14 |
When I generate a C# client for an API using NSwag,
where the API includes endpoints that can be used with multiple Http request types (e.g. POST, GET)
the client generates a method for each request with the same base name, plus a number.
E.g. Using this API: https://api.premiumfunding.net.au/assets/scripts/swagger/v1/... | You can implement and provide an own IOperationNameGenerator:
https://github.com/RSuter/NSwag/blob/master/src/NSwag.CodeGeneration/OperationNameGenerators/IOperationNameGenerator.cs
Another option would be to preprocess the spec and change the “operationId”s to the form “controller_operation” (simple console app based... | OpenAPI | 49,891,178 | 14 |
I'm creating the the API description of our application using Swagger/OpenApi V3 annotations, imported from following dependency:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.1.45</version>
</dependency>
One of the annotations is a @Schema annotatio... | try using @Schema(implementation = ExampleEnum.class, ...), you can add all other properties you want. I would need more info on your implementation but try this first.
| OpenAPI | 59,282,771 | 14 |
I have a bunch of API endpoints that return text/csv content in their responses. How do I document this? Here is what I currently have:
/my_endpoint:
get:
description: Returns CSV content
parameters:
- $ref: '#/components/parameters/myParemeters'
responses:
200:
headers... | Your first example is not valid syntax. Replace with:
responses:
'200':
content:
text/csv: {} # <-----
# Also note the correct syntax for referencing response headers:
headers:
Http-Header-Name: # e.g. X-RateLimit-Remaining
$ref: '#/co... | OpenAPI | 59,722,686 | 14 |
The RabbitMQ windows service will not start:
C:\Program Files (x86)\RabbitMQ Server\rabbitmq_server-3.0.4\sbin>rabbitmq-service.bat start
C:\Program Files (x86)\erl5.10.1\erts-5.10.1\bin\erlsrv: Failed to start service RabbitMQ.
Error: The process terminated unexpectedly.
I can run rabbitmq-server.bat without any prob... | I faced the same problem and was able to solve the problem following the steps mentioned below.
Run the command prompt as Administrator
Navigate to the sbin directory and uninstall the service. rabbitmq-service remove
Reinstall the service rabbitmq-service install
Enable the plugins. rabbitmq-plugins enable rabbitmq_m... | RabbitMQ | 16,001,047 | 31 |
The beloved RabbitMQ Management Plugin has a HTTP API to manage the RabbitMQ through plain HTTP requests.
We need to create users programatically, and the HTTP API was the chosen way to go. The documentation is scarce, but the API it's pretty simple and intuitive.
Concerned about the security, we don't want to pass th... | And for the fun the bash version !
#!/bin/bash
function encode_password()
{
SALT=$(od -A n -t x -N 4 /dev/urandom)
PASS=$SALT$(echo -n $1 | xxd -ps | tr -d '\n' | tr -d ' ')
PASS=$(echo -n $PASS | xxd -r -p | sha256sum | head -c 128)
PASS=$(echo -n $SALT$PASS | xxd -r -p | base64 | tr -d '\n')
echo... | RabbitMQ | 41,306,350 | 31 |
Are there any advantages of using NServiceBus over simply using the .net driver for RabbitMQ (assuming we can replace MSMQ with AMQP). Does NSB provide any additional functionality or abstractions that are not available directly in AMQP.
| Main advantages include (but are not limited to):
Takes care of serialization/deserialization of messages.
Provides a neat model for dispatching messages w. handlers, polymorphic dispatch, arranging handlers in a pipeline etc.
Handles unit of work.
Provides a neat saga implementation.
Gives you a host process that can... | RabbitMQ | 9,558,128 | 31 |
I'm using the official RabbitMQ Docker image (https://hub.docker.com/_/rabbitmq/)
I've tried editing the rabbitmq.config file inside the container after running
docker exec -it <container-id> /bin/bash
However, this seems to have no effect on the rabbitmq server running in the container. Restarting the container obvi... | the config file lives in /etc/rabbitmq/rabbitmq.config so if you mount your own config file with something like this (I'm using docker-compose here to setup the image)
volumes:
- ./conf/myrabbit.conf:/etc/rabbitmq/rabbitmq.config
that should do it.
In case you are having issues that the configuration file get's create... | RabbitMQ | 42,003,640 | 30 |
I'd like to write a simple smoke test that runs after deployment to verify that the RabbitMQ credentials are valid. What's the simplest way to check that rabbitmq username/password/vhost are valid?
Edit: Preferably, check using a bash script. Alternatively, using a Python script.
| As you haven't provided any details about language, etc.:
You could simply issue a HTTP GET request to the management api.
$ curl -i -u guest:guest http://localhost:15672/api/whoami
See RabbitMQ Management HTTP API
| RabbitMQ | 17,148,683 | 30 |
We're using amqplib to publish/consume messages. I want to be able to read the number of messages on a queue (ideally both acknowledged and unacknowledged). This will allow me to show a nice status diagram to the admin users and detect if a certain component is not keeping up with the load.
I can't find any information... | Using pika:
import pika
pika_conn_params = pika.ConnectionParameters(
host='localhost', port=5672,
credentials=pika.credentials.PlainCredentials('guest', 'guest'),
)
connection = pika.BlockingConnection(pika_conn_params)
channel = connection.channel()
queue = channel.queue_declare(
queue="your_queue", dura... | RabbitMQ | 16,691,161 | 30 |
I have installed rabbitmq using helm chart on a kubernetes cluster. The rabbitmq pod keeps restarting. On inspecting the pod logs I get the below error
2020-02-26 04:42:31.582 [warning] <0.314.0> Error while waiting for Mnesia tables: {timeout_waiting_for_tables,[rabbit_durable_queue]}
2020-02-26 04:42:31.582 [info] <0... | TLDR
helm upgrade rabbitmq --set clustering.forceBoot=true
Problem
The problem happens for the following reason:
All RMQ pods are terminated at the same time due to some reason (maybe because you explicitly set the StatefulSet replicas to 0, or something else)
One of them is the last one to stop (maybe just a tiny bit... | RabbitMQ | 60,407,082 | 29 |
I want to use Helm chart of RabbitMQ to set up a cluster but when I try to pass the configuration files that we have at the moment to the values.yaml it doesn't work.
The command that I use:
helm install --dry-run --debug stable/rabbitmq --name testrmq --namespace rmq -f rabbit-values.yaml
rabbit-values.yaml:
rabbitmq... | You can't use Helm templating in the values.yaml file. (Unless the chart author has specifically called the tpl function when the value is used; for this variable it doesn't, and that's usually called out in the chart documentation.)
Your two options are to directly embed the file content in the values.yaml file you'r... | RabbitMQ | 57,706,037 | 29 |
I want to use messaging library in my application to interact with rabbitmq. Can anyone please explain the differences between pika and kombu library?
| Kombu and pika are two different python libraries that are fundamentally serving the same purpose: publishing and consuming messages to/from a message broker.
Kombu has a higher level of abstraction than pika. Pika only supports AMQP 0.9.1 protocol while Kombu can support other transports (such as Redis). More generall... | RabbitMQ | 48,524,536 | 29 |
I'm quite new to these high level concurrency paradigms, and I've started using the scala RX bindings. So I'm trying to understand how RX differs from messaging queues like RabbitMQ or ZeroMQ?
They both appear to use the subscribe/publish paradigm. Somewhere I saw a tweet about RX being run atop RabbitMQ.
Could someone... | It's worth clicking the learn more link on the [system.reactive] tag, we put a fair bit of info there!
From the intro there you can see that Rx is not a message queueing technology:
The Reactive Extensions (Rx) is a library for composing asynchronous and event-based programs using observable sequences and LINQ-style q... | RabbitMQ | 20,740,114 | 29 |
Is there any simple way to install RabbitMQ for Ubuntu? I did the the following:
Add the following line to /etc/apt/sources.list:
deb http://www.rabbitmq.com/debian/ testing main
then install with apt-get:
$ sudo apt-get install rabbitmq-server
But I get the following error every time:
Reading package lists... Done... | Simplest way to install rabbitMQ in ubuntu:
echo "deb http://www.rabbitmq.com/debian/ testing main" | sudo tee /etc/apt/sources.list.d/rabbitmq.list > /dev/null
wget https://www.rabbitmq.com/rabbitmq-signing-key-public.asc
sudo apt-key add rabbitmq-signing-key-public.asc
sudo apt-get update
sudo apt-get install rabbi... | RabbitMQ | 8,808,909 | 29 |
I have been fighting the Django/Celery documentation for a while now and need some help.
I would like to be able to run Periodic Tasks using django-celery. I have seen around the internet (and the documentation) several different formats and schemas for how one should go about achieving this using Celery...
Can someone... | What's wrong with the example from the docs?
from celery.task import PeriodicTask
from clickmuncher.messaging import process_clicks
from datetime import timedelta
class ProcessClicksTask(PeriodicTask):
run_every = timedelta(minutes=30)
def run(self, **kwargs):
process_clicks()
You could write the s... | RabbitMQ | 8,224,482 | 29 |
I'm a new one just start to learn and install RabbitMQ on Windows System.
I install Erlang VM and RabbitMQ in custom folder, not default folder (Both of them).
Then I have restarted my computer.
By the way,My Computer name is "NULL"
I cd to the RabbitMQ/sbin folder and use command:
rabbitmqctl status
But the return me... | ERROR: type should be string, got "https://groups.google.com/forum/#!topic/rabbitmq-users/a6sqrAUX_Fg\ndescribes the problem where there is a cookie mismatch on a fresh installation of Rabbit MQ. The easy solution on windows is to synchronize the cookies \nAlso described here: http://www.rabbitmq.com/clustering.html#erlang-cookie\nEnsure cookies are synchronized across 1, 2 and Optionally 3 below \n\n%HOMEDRIVE%%HOMEPATH%\\.erlang.cookie (usually C:\\Users\\%USERNAME%\\.erlang.cookie for user %USERNAME%) if both the HOMEDRIVE and HOMEPATH environment variables are set\n%USERPROFILE%\\.erlang.cookie (usually C:\\Users\\%USERNAME%\\.erlang.cookie) if HOMEDRIVE and HOMEPATH are not both set\nFor the RabbitMQ Windows service - %USERPROFILE%\\.erlang.cookie (usually C:\\WINDOWS\\system32\\config\\systemprofile)\n\nThe cookie file used by the Windows service account and the user running CLI tools must be synchronized by copying the one from C:\\WINDOWS\\system32\\config\\systemprofile folder.\n" | RabbitMQ | 47,874,958 | 28 |
I am new to RabbitMQ, so please excuse me for asking some trivial questions:
When running a RabbitMQ cluster, if a node fails the load shifts to another node (without stopping the other nodes). Similarly, we can also add new nodes to the existing cluster without stopping existing nodes in the cluster. Is that correct?... |
When running a RabbitMQ cluster, if a node fails the load shifts to another node (without stopping the other nodes). Similarly, we can also add new nodes to the existing cluster without stopping existing nodes in the cluster. Is that correct?
If a node on which the queue was created fails, RabbitMQ will elect a new... | RabbitMQ | 28,207,327 | 28 |
My Java application sends messages to RabbitMQ exchange, then exchange redirects messages to binded queue.
I use Springframework AMQP java plugin with RabbitMQ.
The problem: message comes to queue, but it stays in "Unacknowledged" state, it never becomes "Ready".
What could be the reason?
| Just to add my 2 cents for another possible reason for messages staying in an unacknowledged state, even though the consumer makes sure to use the basicAck method-
Sometimes multiple instances of a process with an open RabbitMQ connection stay running, one of which may cause a message to get stuck in an unacknowledged ... | RabbitMQ | 11,926,077 | 28 |
Right now I'm looking at Play Framework and like it a lot. One of the parts heavy advertised amongst the features offered in Play is Akka.
In order to better understand Akka and how to use it properly, can you tell me what are the alternatives in other languages or products?
How does RabbitMQ compare to it? Is there a ... | I use RabbitMQ + Spring AMQP + Guava's EventBus to automatically register Actor-like messengers using Guava's EventBus for pattern matching the received messages.
The similarity to Spring AMQP and Akka is uncanny. Spring AMQP's SimpleMessageListenerContainer + MessageListener is pretty much equivalent to an Actor.
Ho... | RabbitMQ | 10,268,613 | 28 |
I am looking for a messaging service for a new project that will have to interface some C# applications with some Java applications. I really like RabbitMQ because it seems to have amazing support for both technologies. I see in the RabbitMQ specs that at the moment only AMQP 0-9-1 model is provided.
Is that a show st... | Your question is perfectly addressed in the official protocol overview:
AMQP 1.0
Despite the name, AMQP 1.0 is a radically different protocol
from AMQP 0-9-1 / 0-9 / 0-8, sharing essentially nothing at the wire
level. AMQP 1.0 imposes far fewer semantic requirements; it is
therefore easier to add support for AMQ... | RabbitMQ | 28,402,374 | 27 |
I've been working on getting some distributed tasks working via RabbitMQ.
I spent some time trying to get Celery to do what I wanted and couldn't make it work.
Then I tried using Pika and things just worked, flawlessly, and within minutes.
Is there anything I'm missing out on by using Pika instead of Celery?
| What pika provides is just a small piece of what Celery is doing. Pika is Python library for interacting with RabbitMQ. RabbitMQ is a message broker; at its core, it just sends messages to/receives messages from queues. It can be used as a task queue, but it could also just be used to pass messages between processes, w... | RabbitMQ | 23,766,658 | 27 |
I want to run rabbitmq-server in one docker container and connect to it from another container using celery (http://celeryproject.org/)
I have rabbitmq running using the below command...
sudo docker run -d -p :5672 markellul/rabbitmq /usr/sbin/rabbitmq-server
and running the celery via
sudo docker run -i -t markellul/... | [edit 2016]
Direct links are deprecated now. The new way to do link containers is docker network connect. It works quite similar to virtual networks and has a wider feature set than the old way of linking.
First you create your named containers:
docker run --name rabbitmq -d -p :5672 markellul/rabbitmq /usr/sbin/rabbit... | RabbitMQ | 18,460,016 | 27 |
In my (limited) experience with rabbit-mq, if you create a new listener for a queue that doesn't exist yet, the queue is automatically created. I'm trying to use the Spring AMQP project with rabbit-mq to set up a listener, and I'm getting an error instead. This is my xml config:
<rabbit:connection-factory id="rabbitCon... | Older thread, but this still shows up pretty high on Google, so here's some newer information:
2015-11-23
Since Spring 4.2.x with Spring-Messaging and Spring-Amqp 1.4.5.RELEASE and Spring-Rabbit 1.4.5.RELEASE, declaring exchanges, queues and bindings has become very simple through an @Configuration class some annotatio... | RabbitMQ | 16,370,911 | 27 |
Can you recommend what Python library to use for accessing AMQP (RabbitMQ)? From my research pika seems to be the preferred one.
| My own research led me to believe that the right library to use would be Kombu, as this is also what Celery (mentioned by @SteveMc) has transitioned to. I am also using RabbitMQ and have used Kombu with the default amqplib backend successfully.
Kombu also supports other transports behind the same API. Useful if you n... | RabbitMQ | 5,031,606 | 27 |
I have a reactor that fetches messages from a RabbitMQ broker and triggers worker methods to process these messages in a process pool, something like this:
This is implemented using python asyncio, loop.run_in_executor() and concurrent.futures.ProcessPoolExecutor.
Now I want to access the database in the worker method... | Your requirement of one database connection per process-pool process can be easily satisfied if some care is taken on how you instantiate the session, assuming you are working with the orm, in the worker processes.
A simple solution would be to have a global session which you reuse across requests:
# db.py
engine = cre... | RabbitMQ | 39,613,476 | 26 |
I want to explicitly revoke a task from celery. This is how I'm currently doing:-
from celery.task.control import revoke
revoke(task_id, terminate=True)
where task_id is string(have also tried converting it into UUID uuid.UUID(task_id).hex).
After the above procedure, when I start celery again celery worker -A proj i... | How does revoke works?
When calling the revoke method the task doesn't get deleted from the queue immediately, all it does is tell celery(not your broker!) to save the task_id in a in-memory set(look here if you like reading source code like me).
When the task gets to the top of the queue, Celery will check if is it in... | RabbitMQ | 39,191,238 | 26 |
Imagine the situation:
var txn = new DatabaseTransaction();
var entry = txn.Database.Load<Entry>(id);
entry.Token = "123";
txn.Database.Update(entry);
PublishRabbitMqMessage(new EntryUpdatedMessage { ID = entry.ID });
// A bit more of processing
txn.Commit();
Now a consumer of EntryUpdatedMessage can potentially g... | RabbitMQ encourages you to use publisher confirms rather than transactions. Transactions do not perform well.
In any case, transactions don't usually work very well with a service oriented architecture. It's better to adopt an 'eventually consistent' approach, where failure can be retried at a later date and duplicate ... | RabbitMQ | 17,810,112 | 26 |
it seems like I do have a problem with the rabbitmq and rabbitmq-management docker image on my Windows machine running docker-desktop.
When trying to run it, the following log comes up before it shuts down:
21:01:21.726 [error] Failed to write to cookie file '/var/lib/rabbitmq/.erlang.cookie': enospc
21:01:22.355 [err... | I had exactly the same error and followed the advice of Owen Brown. Unfortunately, deleting the rabbitmq images could not solve my problems but deleting all other redundant images as well (especially the ones of big size) did it for me.
In case you are wondering how much all images are in size, you can check these stat... | RabbitMQ | 63,384,705 | 25 |
My team wants to move to microservices architecture. Currently we are using Redis Pub/Sub as message broker for some legacy parts of our system. My colleagues think that it is naturally to continue use redis as service bus as they don't want spend their time on studying new product. But in my opinion RabbitMQ (especial... | Redis is a fast in-memory key-value store with optional persistence. The pub/sub feature of Redis is a marginal case for Redis as a product.
RabbitMQ is the message broker that does nothing else. It is optimized for reliable delivery of messages, both in command style (send to an endpoint exchange/queue) and publish-su... | RabbitMQ | 52,592,796 | 25 |
I am using amqplib in Node.js, and I am not clear about the best practices in my code.
Basically, my current code calls the amqp.connect() when the Node server starts up, and then uses a different channel for each producer and each consumer, never actually closing any of them. I'd like to know if that makes any sens... | In general, it's not a good practice to open and close connections and channels per message. Connections are long lived and it takes resources to keep opening and closing them. For channels, they share the TCP connection with the connection so they are more lightweight, but they will still consume memory and definitely... | RabbitMQ | 44,358,076 | 25 |
Background
I am making a publish/subscribe typical application where a publisher sends messages to a consumer.
The publisher and the consumer are on different machines and the connection between them can break occasionally.
Objective
The goal here is to make sure that no matter what happens to the connection, or to t... | Background
I originally wanted publish and subscribe with message and queue persistence.
This in theory, does not exactly fit publish and subscribe:
this pattern doesn't care if the messages are received or not. The publisher simply fans out messages and if there are any subscribers listening, good, otherwise it doe... | RabbitMQ | 43,777,807 | 25 |
I'm trying to install and be able to run rabbitmqadmin on a linux machine. Following the instructions described here do not help.
After downloading the file linked, it prompts to copy the file (which looks like a python script) into /usr/local/bin.
Trying to run it by simply invoking rabbitmqadmin results in rabbitmqad... | I spent several hours to figure out this, use rabbitmqadmin on linux environment, Finally below steps solve my issue.
On my ubuntu server, python3 was installed, I checked it using below command,
python3 -V
Step 1: download the python script to your linux server
wget https://raw.githubusercontent.com/rabbitmq/rabbitmq... | RabbitMQ | 36,336,071 | 25 |
All of a sudden when I try to access RabbitMQ it only displays this on screen:
undefined: There is no template at js/tmpl/login.ejs
Any help will be appreciated.
UPDATE:
Now it is showing browser default error:
Connection Refused
| The problem was solved by restarting the Linux server as rabbitMQ commands were hanging and required force stop.
Hope this helps someone.
| RabbitMQ | 33,935,430 | 25 |
I'm using RabbitMQ in C# with the EasyNetQ library. I'm using a pub/sub pattern here. I still have a few issues that I hope anyone can help me with:
When there's an error while consuming a message, it's automatically moved to an error queue. How can I implement retries (so that it's placed back on the originating queu... | The problem you are running into with EasyNetQ/RabbitMQ is that it's much more "raw" when compared to other messaging services like SQS or Azure Service Bus/Queues, but I'll do my best to point you in the right direction.
Question 1.
This will be on you to do. The simplest way is that you can No-Ack a message in Rabbi... | RabbitMQ | 30,914,640 | 25 |
I'm a newcomer to celery and I try to integrate this task queue into my project but I still don't figure out how celery handles the failed tasks and I'd like to keep all those in a amqp dead-letter queue.
According to the doc here it seems that raising Reject in a Task having acks_late enabled produces the same effect ... | I think you should not add arguments=DEAD_LETTER_CELERY_OPTIONS in CELERY_EXCHANGE. You should add it to CELERY_QUEUE with queue_arguments=DEAD_LETTER_CELERY_OPTIONS.
The following example is what I did and it works fine:
from celery import Celery
from kombu import Exchange, Queue
from celery.exceptions import Reject... | RabbitMQ | 38,111,122 | 24 |
The following API call to RabbitMQ:
http -a USER:PASS localhost:15001/api/queues/
Returns a list of queues:
[
{
...
"messages_unacknowledged_ram": 0,
"name": "foo_queue",
"node": "rabbit@queue-monster-01",
"policy": "",
"state": "running",
"vhost": "/"... | URL Encoding did the trick. The URL should be:
localhost:15001/api/queues/%2F/foo_queue
⬆⬆⬆
For the record, I think that REST resources should not be named /, especially not by default.
| RabbitMQ | 33,119,611 | 24 |
So I am using rabbitmqs http api to do some very basic actions in rabbit. It works great in most situations but I am having an issue figuring out how to use it to publish a message to the default rabbitmq exchange. This exchange is always present, cannot be deleted and has a binding to every queue with a routing key eq... | This is the way to publish a message to amq.default:
http://localhost:15672/api/exchanges/%2f/amq.default/publish
with this body
{"properties":{},
"routing_key":"queue_test",
"payload":"message test ",
"payload_encoding":"string"}
routing_key is the queue where you will publish the message.
Following an example usi... | RabbitMQ | 32,486,398 | 24 |
I'm using RabbitMQ as a message queue in a service-oriented architecture, where many separate web services publish messages bound for RabbitMQ queues. Those queues are in turn subscribed to by various consumers, which perform background work; a pretty vanilla use-case for RabbitMQ.
Now I'd like to change some of the q... | Queues bindings can be added and removed at runtime without any impact on clients, unless clients manually modify bindings. So if your question only about bindings just change them via CLI or web management panel and skip what written below.
It's a common problem to make back-incompatible changes, especially in heterog... | RabbitMQ | 25,274,182 | 24 |
Is there any way to count how many time a job is requeued (via Reject or Nak) without manually requeu the job?
I need to retry a job for 'n' time and then drop it after 'n' time.
ps : Currently I requeue a job manually (drop old job, create a new job with the exact content and an extra Counter header if the Counter is ... | Update from 2023 based on quorum queue's way of poison message handling:
Quorum queues keep track of the number of unsuccessful delivery
attempts and expose it in the "x-delivery-count" header that is included with any redelivered message.
Original answer (before queue and stream queues were added):
There are redeliv... | RabbitMQ | 25,226,080 | 24 |
I've got a python worker client that spins up a 10 workers which each hook onto a RabbitMQ queue. A bit like this:
#!/usr/bin/python
worker_count=10
def mqworker(queue, configurer):
connection = pika.BlockingConnection(pika.ConnectionParameters(host='mqhost'))
channel = connection.channel()
channel.queue_d... | I appear to have solved this by moving where basic_qos is called.
Placing it just after channel = connection.channel() appears to alter the behaviour to what I'd expect.
| RabbitMQ | 12,426,927 | 24 |
I'm doing research to figure out what messaging solution to settle on for our future products and I can't really figure this one out.
There is a bunch of AMQP 0.9.1 implementations (RabbitMQ, Apache Qpid, OpenAMQ, to name a few), but no AMQP 1.0 implementation, although 1.0 has been finalized October 2011. Well, except... | AMQP 1.0 is an alternative to AMQP 0-9-1 in name only. The two are so different that it might have been clearer to give them different names.
Choosing a current 0-9-1 implementation does not limit you:
0-9-1 defines a broker and messaging model, while 1.0 defines a messaging transport. Therefore it is possible to com... | RabbitMQ | 11,928,655 | 24 |
OK, I have been reading about the celery and rabbitmq, while I appreciate the effort of the project and the documentation, I am still confused about a lot of things.
http://www.celeryproject.org/
http://ask.github.com/django-celery/
I am super confused about if celery is only for Django or a standalone server, as the ... | Well not a book but I recently did setup in Dotcloud for Django+Celery, and here's the short doc:
http://web.archive.org/web/20150329132442/http://docs.dotcloud.com/tutorials/python/django-celery/
It's intended for simple tasks to be run asynchronously. There is a dotcloud-specific setup, but the rest might clear thing... | RabbitMQ | 7,843,345 | 24 |
There are a couple of threads talking about license issue. Mostly focusing on GPL/LGPL/BSD. I am trying to use RabbitMQ in commercial applications, which is licensed under Mozilla Public License(MPL). Is MPL friendly to commercial use?
I found a different question on Stack Overflow, and one of the comments mentions:
M... | In a more serious tone, you should always consult to your lawyer, but it could be helpful if you read the annotated MPL 1.1 at: http://www.mozilla.org/MPL/MPL-1.1-annotated.html but it basically means that the files can be combined with proprietary files on a "larger work", still, it would be wise if you read the annot... | RabbitMQ | 2,073,477 | 24 |
I think I am missing something here..I am trying to create simple rabbit listner which can accept custom object as message type. Now as per doc it says
In versions prior to 1.6, the type information to convert the JSON had to be provided in message headers, or a custom ClassMapper was required. Starting with version 1.... | If you are using boot, you can simply add a Jackson2JsonMessageConverter @Bean to the configuration and it will be automatically wired into the listener (as long as it's the only converter). You need to set the content_type property to application/json if you are using the administration console to send the message.
C... | RabbitMQ | 41,914,665 | 23 |
The RabbitMQ documentation states:
Default Virtual Host and User
When the server first starts running, and detects that its database is uninitialised or has been deleted, it initialises a fresh database with the following resources:
a virtual host named /
The api has things like:
/api/exchanges/#vhost#/?name?/bindin... | As write here: http://hg.rabbitmq.com/rabbitmq-management/raw-file/3646dee55e02/priv/www-api/help.html
As the default virtual host is called "/", this will need to be encoded as "%2f".
so:
/api/exchanges/%2f/{exchange_name}/bindings/source
full:
http://localhost:15672/api/exchanges/%2f/test_ex/bindings/source
as r... | RabbitMQ | 37,124,375 | 23 |
I have a nodejs client that uses bramqp for connecting to RabbitMQ server. My client can connect to a Rabbit MQ server in localhost and works well. But it's unable to connect to a remote RabbitMQ server on other machine. I opened port 5672 in the remote server, so I think that the problem is in the configuration of ra... | The problem seems the new rabbitmq access control policy
Please read this post:
Can't access RabbitMQ web management interface after fresh install
I think it can help you!
| RabbitMQ | 23,487,238 | 23 |
I'm spec'ing a design right now that uses RabbitMQ as a message queue. The message are going to have a JSON body, and for one message in particular I'd like to add a small binary file.
What I'd like to know is, should the binary file's data be part of the JSON message, or can it be appended to the message separately?
| Since RabbitMQ message payload is just a binary array you should encode your message body with 3 fields:
File size
Binary data of a file
Json
I disagree with a previous answer about embedding a file in json.
If you encode file data inside of json you will get wasted space because of json escaping + unnecessary CPU ... | RabbitMQ | 22,070,639 | 23 |
II'm trying to make the "hello world" application from here: RabbitMQ Hello World
Here is the code of my producer class:
package com.mdnaRabbit.producer;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;
import java.io.IOException;
public class A... | To deal with it I installed RabbitMQ server. If rabbitmq-server is not installed this error will be thrown.
Make sure you have installed RabbitMQ server and it's up and running by hitting http://localhost:15672/
| RabbitMQ | 15,434,810 | 23 |
Eventhough redis and message queueing software are usually used for different purposes, I would like to ask pros and cons of using redis for the following use case:
group of event collectors write incoming messages as key/value . consumers fetch and delete processed keys
load starting from 100k msg/s and going beyond ... | Given your requirements I would try Redis. It will perform better than other solutions and give you much finer grained control over the persistence characteristics. Depending on the language you're using you may be able to use a sharded Redis cluster (you need Redis bindings that support consistent hashing -- not all... | RabbitMQ | 7,506,118 | 23 |
I have one .NET 4.5.2 Service Publishing messages to RabbitMq via MassTransit.
And multiple instances of a .NET Core 2.1 Service Consuming those messages.
At the moment competing instances of the .NET core consumer service steal messages from the others.
i.e. The first one to consume the message takes it off the queu... | It sounds like you want to publish messages and have multiple consumer service instances receive them. In that case, each service instance needs to have its own queue. That way, every published message will result in a copy being delivered to each queue. Then, each receive endpoint will read that message from its own q... | RabbitMQ | 57,209,798 | 22 |
I was having trouble, so I went into the registry and removed the service entry for rabbitmq. Now when I try to reinstall it says it already exists but it doesn't start (since I removed it) and I can do a sc delete rabbitmq. How do I totally remove all traces of it and reinstall from scratch? I guess it exists somew... | I would suggest as follows:
sudo apt-get remove --auto-remove rabbitmq-server
sudo apt-get purge --auto-remove rabbitmq-server
It will uninstall rabbitmq and purge all data (users, vhost..)
| RabbitMQ | 39,664,283 | 22 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.