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'm new to React, and I'd like to ask a strategy question about how best to accomplish a task where data must be communicated between sibling components. First, I'll describe the task: Say I have multiple <select> components that are children of a single parent that passes down the select boxes dynamically, composed fr...
TLDR: Yes, you should use a props-from-top-to-bottom and change-handlers-from-bottom-to-top approach. But this can get unwieldy in a larger application, so you can use design patterns like Flux or Redux to reduce your complexity. Simple React approach React components receive their "inputs" as props; and they communica...
Flux
36,143,767
35
A Egghead tutorial teaches it like this: var React = require('react'); var Router = require('react-router'); var routes = require('./config/routes'); Router.run(routes, function(Root){ React.render(<Root />, document.getElementById('app')); }); Yet I get this error: Uncaught TypeError: Router.run is not a function...
Since the release of React Router v1.0, the run method has been removed, these breaking changes are documented in the upgrade guide. Your code would roughly translate to this: ReactDOM.render(<Router>{routes}</Router>, document.getElementById('app')) https://github.com/rackt/react-router/blob/832c42946c874fe56ffde00...
Flux
32,682,854
33
I am going around React.js and my question is simple: does my app have to be a single page app if I use React? If no then how do I control components outside of them? By FLUX? Any other standard methods? If yes then are there any libraries to perform permissions/access validation on the client side for React? Thanks a ...
A react application need not be a single page application. React provides you with a way model HTML in terms of classes with specific render logic, but doesn't impose any sort of specific application logic like single vs multi page. I'm not quite sure I understand the rest of your questions, but I think you are essent...
Flux
32,130,937
31
For example... export const user = (state = { id: localStorage.getItem('id'), name: localStorage.getItem('name'), loggedInAt: null }, action) => { case types.LOGIN: localStorage.setItem('name', action.payload.user.name); localStorage.setItem('id', action.payload.user.id); return { ...state,...
Redux createStore 2nd param is intended for store initialization: createStore(reducer, [initialState], [enhancer]) So you can do something like this: const initialState = { id: localStorage.getItem('id'), name: localStorage.getItem('name'), loggedInAt: null }; const store = createStore(mainReducer, initialState...
Flux
36,580,963
31
I'm a newbie in redux and es6 syntax. I make my app with official redux tutorial, and with this example. There is JS snippet below. My point - to define REQUEST_POST_BODY and RECEIVE_POST_BODY cases in posts reducer. Main difficult - to find and update right object in store. I try to use code from example: return O...
With Arrays If you'd prefer to stick with arrays, then you can write a reducer that just tackles single post objects. export default function reducePost(post, action) { if(post.id !== action.id) return post; switch(action.type) { case REQUEST_POST_BODY: return Object.assign({}, post, { isFetching: true }); ...
Flux
36,031,590
29
I am a bit confused by the statements: "Renders the whole application" and "Passing state to child components". Example 1: I have a todos app with a AppComponent and TodosListComponent. The AppComponent grabs the array of todos from the store and passes it as a property to the TodosListComponent. Example 2: I have a hu...
There are a few ways you can handle this. I think they're all valid and have their own trade-offs. Get all the state and pass pieces of it to children This is the technique you specifically asked about. Using this method, you'll have some function or method available to your top-level component that turns all the data ...
Flux
26,563,933
26
When reading the redux docs I found this: Still, you should do your best to keep the state serializable. Don't put anything inside it that you can't easily turn into JSON. So my question is, what's the benefit of keeping state serializable? Or, what difficulties I may have if I put non-serializable data into store? A...
Directly from the redux FAQs: Can I put functions, promises, or other non-serializable items in my store state? It is highly recommended that you only put plain serializable objects, arrays, and primitives into your store. It's technically possible to insert non-serializable items into the store, but doing so can brea...
Flux
40,941,079
26
I'm trying to replace a Backbone.Marionette App to React and am facing difficulty thinking about query params. I think I'm missing a really simple peace in understanding this pattern so I apologize if this question is totally nonsense. I would appreciate any support or just pointing me to some direction that I can go...
I would consider best practice to be the submit button only setting the location query (username). The rest should be taken care by the main react component that is assigned as router component. By this, you can be sure that anytime one revisits or shares the url, they can get the same results. And this is very generic...
Flux
32,208,655
24
I'm a bit stuck thinking on how to implement a reducer where its entities can have children of the same type. Let's take reddit comments as an example: each comment can have child comments that can have comments themselves etc. For simplification reason, a comment is a record of type {id, pageId, value, children}, with...
The official solution to this is to use normalizr to keep your state like this: { comments: { 1: { id: 1, children: [2, 3] }, 2: { id: 2, children: [] }, 3: { id: 3, children: [42] }, ... } } You're right that you'd need to connect() the Comment compo...
Flux
32,798,193
24
Tools: Reactjs 0.14.0 Vanilla Flux I need unique identifiers for 2 reasons: Child Reconciliation Keeping track of what child was clicked So let's say I have a list of messages that looks like this: [ { id: 1241241234, // <-----The unique id is kept here authorName: "Nick" text: "Hi!" }, ...
key and ref aren't really 'props'. They're used internally by react and not passed to components as props. Consider passing it as a prop such as 'id'.
Flux
33,661,511
24
I would like to pass router params into Vuex actions, without having to fetch them for every single action in a large form like so: edit_sport_type({ rootState, state, commit }, event) { const sportName = rootState.route.params.sportName <------- const payload = {sportName, event} <------- commit(...
To get params from vuex store action, import your vue-router's instance, then access params of the router instance from your vuex store via the router.currentRoute object. Sample implementation below: router at src/router/index.js: import Vue from 'vue' import VueRouter from 'vue-router' import routes from './routes' ...
Flux
42,178,851
23
A common question of newcomers to React is why two-way data binding is not a built-in feature, and the usual response includes an explanation of unidirectional data flow along with the idea that two-way data binding is not always desirable for performance reasons. It's the second point that I'd like to understand in mo...
2 way data binding implications Starting from the first part of your question, there are two primary reasons for react not going with two way data binding: A single source of truth for data changes in a React app, hence less chances of bugs and easier debugging Performance benefits In React, we can share state among ...
Flux
48,931,995
23
My code https://gist.github.com/ButuzGOL/707d1605f63eef55e4af So when I get sign-in success callback I want to make redirect, redirect works through dispatcher too. And I am getting Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch. Is there any hack to call action in the middle ?
I don't see where in the gist that you posted you are doing the redirect. I only see the AUTH_SIGNIN and AUTH_SIGNIN_SUCCESS actions, and they look pretty straightforward. But no, there is no hack to create an action in the middle of a dispatch, and this is by design. Actions are not supposed to be things that cause ...
Flux
26,581,587
21
From the discussion here it seems that the state of Redux reducers should be persisted in a database. How does something like user authentication works in this instance? Wouldn't a new state object be created to replace the previous state in the database for every user (and their application state) created and edited? ...
From the discussion here it seems that the state of Redux reducers should be persisted in a database. To persist the state or not, it's likely not a concern of Redux at all. It's more up to application logic. If something happens in an application, like data upload to server, obviously you need to save state (or a sl...
Flux
33,726,644
19
Is there a way to cancel an action or ignore it? Or rather what is the best/recommended way to ignore an action? I have the following action creator and when I input an invalid size (say 'some_string') into the action creator, in addition to getting my own warning message I also get: Uncaught Error: Actions must be pla...
Ignoring actions in Action Creators is basically a way of treating them as Command Handlers, not Event Creators. When the User clicks the button it’s some kind of Event though. So there are basically two ways how to solve the issue: The condition is inside action creator and thunk-middleware is used const cancelEdit =...
Flux
34,184,677
18
I'm using ReactJs with Redux and on some tutorials and codes I see people suggesting and using normalizr to keep the state flat. But what is the real advantage in keeping it flat ? Will I encounter any problems if I don't ? Is it necessary ?
Three main reasons: Updating nested Javascript objects immutably generally results in uglier code that is harder to maintain, unless you use a utility library to wrap up the process Immutably updating nested data requires that you return new copies of all items in the nesting hierarchy. Since components generally do ...
Flux
38,842,454
17
For the past weeks I've been trying to learn React and Redux. Now I have met a problem thay I haven't found a right answer to. Suppose I have a page in React that gets props from the link. const id = this.props.params.id; Now on this page, I'd like to display an object from STORE with this ID. const initialState = [...
You could use the mapStateToProps function to query the store when you connect the component to redux: import React from 'react'; import { connect } from 'react-redux'; import _ from 'lodash'; const Foo = ({ item }) => <div>{JSON.stringify(item)}</div>; const mapStateToProps = (state, ownProps) => ({ item: _.find(s...
Flux
34,840,994
16
At times I have components with a large amounts of properties. Is there any inherent problem with this? e.g. render() { const { create, update, categories, locations, sectors, workTypes, organisation } = this.props; // eslint-disable-line no-shadow return ( <div className="job-container"> <JobForm ...
I think you have justly recognized a code smell. Anytime you have that many inputs(props) to a function(component), you have to question, how do you test this component with all the permutations of argument combinations. Using {...this.props} to pass them down only cuts down on the typing, sort of like spraying Febre...
Flux
37,695,557
16
In response to a state change, I want to trigger another state change. Is that inherently a bad idea? The specific sort of scenario is that the component is modeled as a state machine that renders different information according to the value of this.state.current_state. But external events can prompt it to experience a...
shouldComponentUpdate is intended specifically to determine if the component should update at all. To do things like: if (nextState.counter == this.state.counter && nextProps.foo == this.Props.foo) { return false; } componentWillReceiveProps is for responding to external (props) changes. There is no equivalent compo...
Flux
33,290,189
14
I'm just starting to use flux (with redux for now) and am wondering how relationships are supposed to be handled. For an example we can use Trello that has boards with columns that contains cards. One approach would be to have one store/reducer for boards and have all the data in it there but that means some very fat s...
Yes, using ids across multiple stores much like a relational database is the way to do it right. In your example, let's say you want to optimistically put a new card in a particular column, and that a card can only be in one column (one column to many cards). The cards in your CardStore might look like this: _cards:...
Flux
31,641,466
13
I have sign in component, which should be available for unauthenticated users. And right after the authentication this component should become unavailable. var routes = ( <Route handler={App}> <Route name="signIn" handler={signIn}/> {/* redirect, if user is already authenticated */} { l...
Instead of checking your auth-flow and conditionally rendering particular routes, I would recommend another approach: If you're using react-router 0.13.x, I would recommend using the willTransitionTo methods on your components when you need to check authentication. It is called when a handler is about to render, giving...
Flux
32,804,269
13
I'm creating a simple CRUD app using Facebook's Flux Dispatcher to handle the creation and editing of posts for an English learning site. I currently am dealing with an api that looks like this: /posts/:post_id /posts/:post_id/sentences /sentences/:sentence_id/words /sentences/:sentence_id/grammars On the show and ed...
But no, there is no hack to create an action in the middle of a dispatch, and this is by design. Actions are not supposed to be things that cause a change. They are supposed to be like a newspaper that informs the application of a change in the outside world, and then the application responds to that news. The stores ...
Flux
32,240,309
12
So say you have a chat aplication with this component structure: <ChatApp> <CurrentUserInfo>...</CurrentUserInfo> <ChatsPanel>...</ChatsPanel> <SelectedChatPanel> <MessagesList> <MessageBaloon> <MessageText></MessageText> <MessageUserHead></MessageUserHead> </MessageBaloon> ....
(UPDATE: Having spent some time on option 4, I personally think it's the way to go. I published a library, react-redux-controller built around this approach.) There are a few approaches that I know of from getting data from your root component, down to your leaf components, through the branches in the middle. Props ch...
Flux
34,299,460
12
I don't understand why we need Flux with React as React itself let's us maintain the state of the application. Every component has an initial state and the state can be changed by user actions or any other asynchronous JavaScript. Why is React called as only a view library when it can let's us define state of the appli...
In theory you don't need flux. In small applications you don't need flux for sure. But what if your application consist of hundreds components? And one of your component is form. User populate this form and you send its content to server. And get response from server with new data. And assume that this response data a...
Flux
35,924,036
12
I've been learning React and Flux over the past few months, and one thing I've not yet dealt with is displaying error messages to users. Specifically, error messages that occur as a result of an ajax http request within a flux action creator method. A simple example is user sign in - if the sign in ajax request fails ...
Since you marked the question with Redux tag, I'm assuming you use Redux. If so, this real-world example shows error handling. There's a reducer that reacts to any action with error field: // Updates error message to notify about the failed fetches. function errorMessage(state = null, action) { const { type, error } ...
Flux
31,822,706
11
I am using reactjs and the flux architecture in a project I'm working on. I am a bit puzzled by how to break up nested data correctly into stores and why I should split up my data into multiple stores. To explain the problem I'll use this example: Imagine a Todo application where you have Projects. Each project has tas...
There are pro's and cons to use one store or different stores. Some implementations of flux specifically favour one store to rule them all, so to speak, while others also facilitate multiple stores. Whether one store or multiple stores suit your needs, depend on a) what your app does, and b) which future developments o...
Flux
33,107,081
11
There is interesting article which describes 4 main classes exposed in Flux Utils. Store ReduceStore MapStore (removed from 3.0.0) Container But it's not super clear what should be used for certain situations. There are only 2 examples for ReduceStore and Container, but no samples for others unfortunately. Could you ...
By poking through the code and reading through the method documentation, here's what I can work out (I have not used these classes myself, as I use other Flux frameworks). It's actually useful to go in almost reverse order for these. Container This is not a subclass of FluxStore because it is, unsurprisingly, not a sto...
Flux
35,071,384
11
I have Action type defined like this: type Action = { type: 'DO_X' } | { type: 'DO_Y', payload: string } | { type: 'DO_Z', payload: number } It's a union type where each member is a valid action. Now I'd like to create a function createAction that accepts type and returns a new function that accept...
The canonical answer to this question depends on your exact use case. I'm going to assume that you need Action to evaluate exactly to the type you wrote; that is, an object of type: "DO_X" does not have a payload property of any kind. This implies that createAction("DO_X") should be a function of zero arguments, whil...
Flux
45,464,815
11
I've been using Vuex, and it's adherence to only altering state through it's mutators or actions makes me think your store should only include as flat an object as you can, with only primitives types. Some threads even prescribe normalising your data (so instead of nested object trees you have objects with arrays of id...
Yes. You are absolutely right in what you are thinking. State containers like Redux, Vuex are supposed to hold your data constructs and not functions. It is true that functions in JavaScript are simply objects which are callable. You can store static data on functions too. But that still doesn't qualify as pure data. I...
Flux
54,345,327
11
I want to use some abstraction in the creation of my React components. For example: class AbstractButton extends React.Component { render() { return ( <button onClick={this.props.onClick} className={this.definitions.className}> {this.props.text} </button> } } class PrimaryB...
Generally speaking, there's no reason not to use composition here instead of deep inheritance: class Button extends React.Component { render() { return (<button onClick={this.props.onClick} className={this.props.className} > {this.props.text} </button>)...
Flux
33,894,609
10
How can I update redux's state from a text input? I'm trying to do a very simple "Hello World" with a text input. When someone types into the text input, it should update my store's "searchTerm" value. I can't figure out these things: 1. How can I get and pass the input's value into it's "onChange" handler? 2. The "s...
You should use this.props.search when binding the action creator to the change event: <input type="text" placeholder="Search" onChange={(event) => this.props.search(event.target.value)} />
Flux
34,474,272
10
I am a bit lost on what to keep in the state tree of Redux. I saw two conflicting statements on what to store in the state tree(s). React doc tell us that only user input should be stored in state trees. The original list of products is passed in as props, so that's not state. The search text and the checkbox seem t...
React documentation about the View Component state, but Redux documentation about the Application state. So, there is no conflicts between definitions. If we talk about Redux - you make all your components without state (and transform stateless root component to stateful with help of react-redux's connect function). I...
Flux
34,969,754
10
React uses Flux architecture and it is said in https://reactjs.org/docs/thinking-in-react.html that React has two models - state and props. And there are some suggestions for model management in React https://reactjs.org/community/model-management.html - but all of this seems to some additional layers to enhance the Fl...
The most basic way is shown in following snippet: const Customer = ({ name, age }) => ( <div> <p>Name: {name}</p> <p>Age: {age}</p> </div> ); const App = () => [{ name: "Bert", age: 22 }, { name: "Alfons", age: 45 }].map( ({ name, age }, i) => ( <> <Customer key={i} name={name} age={age...
Flux
56,622,793
10
As indicated in the official loadimpact/k6 documentation, we are able to execute a single k6 script as follows: k6 run ../tests/http_get.js How would I go about executing multiple script files in a single run? Specifically all scripts that reside in a given local directory. Something like: k6 run ../tests/ Is this ...
Depending on your setup there are a couple different ways you can solve this. A pretty straight forward way is to fork the k6 run command inside bash. #!/bin/sh k6 run test1_spec.js & k6 run test2_spec.js & k6 run test3_spec.js You could easily write some more complicated bash scripting to read in everything from th...
k6
49,113,558
13
Having an application that runs with an insecure certificate results in an error from k6. time="2017-11-29T14:15:16Z" level=warning msg="Request Failed" error="Put https://xxxxxxx: x509: certificate signed by unknown authority"
You need to add the insecureSkipTLSVerify: true in options or add the --insecure-skip-tls-verify flag. https://docs.k6.io/docs/options
k6
47,555,244
10
I would like to leverage Celery (with RabbitMQ as backend MQ) to execute tasks of varying flavors via different Queues. One requirement is that consumption (by the workers) from a particular Queue should have the capability to be paused and resumed. Celery, seems to have this capability via calling add_consumer and ...
To resume from queue, you need to specify queue name as well as target workers. Here is how to do it. app.control.add_consumer(queue='high', destination=['celery@asus']) Here is add_consumer signature def add_consumer(state, queue, exchange=None, exchange_type=None, routing_key=None, **options): In your...
RabbitMQ
45,784,824
13
I want to run some acceptance tests for my services that are using rabbitMq but I want to ignore all that require inter-service communication (amqp). The problem however is that Spring tries to connect to the (non-exisiting) rabbit host on startup so it can register its consumers. It does that for each method that is ...
I've had a similar problem, but solved it with spring.rabbitmq.listener.direct.auto-startup=false SpringBoot version 2.2.4.RELEASE Spring framework version 5.2.3.RELEASE
RabbitMQ
44,927,085
13
I'm using postwait/node-amqp (link) to connect to a variety of RabbitMQ exchanges and queues in our organization. As my project has moved from dev to production I've encountered several issues with queues not being setup correctly or passwords being incorrect etc. In the latter case, it's obvious, I'll get a ECONNREFU...
In amqp, queues and exchanges are concepts unrelated to a connection, they don't listen or broadcast, and you can't connect to those, only to a broker. The RabbitMQ server does of course accept network connections, and the protocol defines a logical Connection on top of the transport, this connection includes a heartbe...
RabbitMQ
36,137,343
13
I am a newbie to RabbitMQ, hence need guidance on a basic question: Does RabbitMQ send messages to consumer as they arrive? OR Does RabbitMQ send messages to consumer as they become available? At message consumption endpoint, I am using com.rabbitmq.client.QueueingConsumer. Looking at the sprint client source code...
TLDR: you poll messages from RabbitMQ till the prefetch count is exceeded in which case you will block and only receive heart beat frames till the fetch messages are ACKed. So you can poll but you will only get new messages if the number of non-acked messages is less than the prefetch count. New messages are put on the...
RabbitMQ
24,309,230
13
TL;DR How to create Spring Boot AMQP connection factory programatically? Hey, In order to connect to my RabbitMQ I added these to my application.properties file of my Spring Boot app: spring.rabbitmq.host=host spring.rabbitmq.port=5672 spring.rabbitmq.username=myapp spring.rabbitmq.password=mypass And according to my ...
@Bean public ConnectionFactory connectionFactory() { CachingConnectionFactory connectionFactory = new CachingConnectionFactory(); connectionFactory.setAddresses(address); connectionFactory.setUsername(username); connectionFactory.setPassword(password); return connectionFactory; }
RabbitMQ
54,002,827
12
I am trying to connect to a remote rabbitmq server. I have the correct credentials and vhost exists on the remove server, but I cannot connect. I get the error pika.exceptions.ProbableAccessDeniedError: (530, 'NOT_ALLOWED - vhost test_vhost not found') I have struggled with this for a while but I can't seem to get...
For me, before: AMQP_URL = 'amqp://guest:guest@localhost:5672/hostname' after: AMQP_URL = 'amqp://guest:guest@localhost:5672' it works.
RabbitMQ
53,102,929
12
We are planning to use Kafka for queueing in our application. I have some bit of experience in RabbitMQ and Spring. With RabbitMQ and Spring, we used to manage queue creation while starting up the spring service. With Kafka, I'm not sure what could be the best way to create the topics? Is there a way to manage the to...
In spring it is possible to create topics during the start of the application using beans: @Bean public KafkaAdmin admin() { Map<String, Object> configs = new HashMap<>(); configs.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, StringUtils.arrayToCommaDelimitedString(kafkaEmbedded().getBrokerAddress...
RabbitMQ
50,909,458
12
I'm trying to setup RabbitMQ in a model where there is only one producer and one consumer, and where messages sent by the producer are delivered to the consumer only if the consumer is connected, but dropped if the consumer is not present. Basically I want the queue to drop all the messages it receives when no consumer...
After a bit more research, I discovered that one of the assumptions in my question regarding x-message-ttl was wrong. I overlooked a single sentence from the RabbitMQ documentation: Setting the TTL to 0 causes messages to be expired upon reaching a queue unless they can be delivered to a consumer immediately https://w...
RabbitMQ
45,327,819
12
I am trying to use RabbitMQ HTTP REST client to publish messages into the queue. I am using the following url and request http://xxxx/api/exchanges/xxxx/exc.notif/publish { "routing_key":"routing.key", "payload":{ }, "payload_encoding":"string", "properties":{ "headers":{ "notif_d":"TEST", "notif_k...
Try with { "properties": { "content-type": "application/json" }, "routing_key": "testKey", "payload": "1234", "payload_encoding": "string" }
RabbitMQ
44,905,126
12
I'm running a Django app in an EC2 instance, which uses RabbitMQ + Celery for task queuing. Are there any drawbacks to running my RabbitMQ node from the same EC2 instance as my production app?
The answer to this questions really depends on the context of your application. When you're faced with scenarios you should always consider a few things. Seperation of concerns Here, we want to make sure that if one of the systems are not responsible for the running of other systems. This includes things like If the...
RabbitMQ
44,196,151
12
We have two servers, Server A and Server B. Server A is dedicated for running django web app. Due to large number of data we decided to run the celery tasks in server B. Server A and B uses a common database. Tasks are initiated after post save in models from Server A,webapp. How to implement this idea using rabbitmq i...
You have 2 servers, 1 project and 2 settings(1 per server). server A (web server + rabbit) server B (only celery for workers) Then you set up the broker url in both settings. Something like this: BROKER_URL = 'amqp://user:password@IP_SERVER_A:5672//' matching server A to IP of server A in server B settings. For now, an...
RabbitMQ
44,113,578
12
I'm using RabbitMQ's round robin feature to dispatch messages between multiple consumers but having only one of them receive the actual message at a time. My problem is that my messages represent tasks and I would like to have local sessions (state) on my consumers. I know beforehand which messages belong to which sess...
If you don't want to go for an orchestration service, you can try a topology like that instead: For the simplicity sake I assume that your processId is used as the routing key (in the real world you may want to store it in the header and use header exchange instead). An incoming message will be accepted by the Incomin...
RabbitMQ
43,001,689
12
I'm new to RabbitMQ, and I'm somewhat lost in the documentation. Currently, as an example, I'm trying to build a small mailer-service that listens to a queue, but I'm somewhat stuck on where I should put the parameters that my service has (destination, subject, ...) Should I put them inside some encoded format (json), ...
I wouldn't use headers for what you are trying to do. That information belongs in the body of the message, in my opinion. Look at it this way: The body of the message should contain everything you need to complete the work requested. In this case, it would be the sender, subject, email content, etc. Headers on the ot...
RabbitMQ
42,593,804
12
I am facing an issue in receiving a message from RabbitMQ. I am sending a message like below HashMap<Object, Object> senderMap=new HashMap<>(); senderMap.put("STATUS", "SUCCESS"); senderMap.put("EXECUTION_START_TIME", new Date()); rabbitTemplate.convertAndSend(Constants.ADAPTOR_OP_QUEUE...
it leads to an exception What exception? TypeId: com.diff.approach.JobListenerDTO That means you are sending a DTO, not a hash map as you describe in the question. If you want to remove the typeId header, you can use a message post processor... rabbitTemplate.convertAndSend(Constants.INPUT_QUEUE, dto, m -> { m....
RabbitMQ
39,443,850
12
I am writing an automated test to test a consumer. So far I did not need to include a header when publishing messages but now I do. And it seems like its lacking documentation. This is my publisher: class RMQProducer(object): def __init__(self, host, exchange, routing_key): self.host = host self.ex...
You would use pika.BasicProperties to add headers. channel.basic_publish(exchange=self.exchange, routing_key=self.routing_key, properties=pika.BasicProperties( headers={'key': 'value'} # Add a key/value header ), ...
RabbitMQ
37,682,184
12
Just want to know the meaning of the parameters in worker.py file: def callback(ch, method, properties, body): print " [x] Received %r" % (body,) What do ch, method, and properties mean?
ch "ch" is the "channel" over which the communication is happening. Think of a RabbitMQ connection in two parts: the TCP/IP connection channels within the connection the actual TCP/IP connection is expensive to create, so you only want one connection per process instance. A channel is where the work is done with Ra...
RabbitMQ
34,202,345
12
I have an existing queue created in RabbitMQ. It can be created with or without x-dead-letter-exchange parameter. I am creating a consumer of this queue in Spring using the RabbitTemplate. When I declare the queue, I don't want to specify the x-dead-letter-exchange parameter. I would like the template to somehow figure...
Yes, The possible cause is - if you declare some queues manually and later your program (client in code) tries to create one (based on the settings you had in code) then you get this error. The reason behind it is when your code (client application) tries to access one queue. It gets a signal from the server that the c...
RabbitMQ
31,938,638
12
I am sending a normal message through a producer to RabbitMQ and then I send a second message with the expiration attribute assigned to a value. Then using the rabbitmqctl list_queues command I monitor the status of the messages. I found that if I send a normal message first and then a message with expiration, the rabb...
Looks like you missed some of the documentation on this feature. If you read the RabbitMQ documentation on per-message TTL (expiration), you will notice the following warning for exactly the behavior you are seeing (emphasis added): Caveats While consumers never see expired messages, only when expired messages reach ...
RabbitMQ
27,991,503
12
I'm new to rabbitmq and pika, and is having trouble with stopping consuming. channel and queue setting: connection = pika.BlockingConnection(pika.ConnectionParameters('localhost')) channel = connection.channel() channel.queue_declare(queue=new_task_id, durable=True, auto_delete=True) Basically, consumer and producer a...
I had the same problem. It seems to be caused by the fact that internally, start_consuming calls self.connection.process_data_events(time_limit=None). This time_limit=None makes it hang. I managed to workaround this problem by replacing the call to channel.start_consuming() with its implemenation, hacked: while channel...
RabbitMQ
27,624,166
12
Can someone please explain what is going on behind the scenes in a RabbitMQ cluster with multiple nodes and queues in mirrored fashion when publishing to a slave node? From what I read, it seems that all actions other than publishes go only to the master and the master then broadcasts the effect of the actions to the s...
Can someone please explain what is going on behind the scenes in a RabbitMQ cluster with multiple nodes and queues in mirrored fashion when publishing to a slave node? This blog outlines exactly what happens. But what happens when I publish to a slave node? Will this node do the same thing of sending first the messa...
RabbitMQ
27,104,726
12
This is a long one. I have a list of usernames and passwords. For each one I want to login to the accounts and do something things. I want to use several machines to do this faster. The way I was thinking of doing this is have a main machine whose job is just having a cron which from time to time checks if the rabbitmq...
The problem is that you're making the thread daemonic: td = Threaded_worker() td.setDaemon(True) # Shouldn't do that. td.start() Daemonic threads will be terminated as soon as the main thread exits: A thread can be flagged as a “daemon thread”. The significance of this flag is that the entire Python program exits ...
RabbitMQ
25,489,292
12
I am trying to connect to RabbitMQ with EasyNetQ. RabbitMQ is on remote VM. _rabbitBus = RabbitHutch.CreateBus( string.Format("host={0};virtualhost={1}", _hostSettings.Host, _hostSettings.VHost), x => x.Register<IEasyNetQLogger>(l => _logger)); _rabbitBus.Subscribe<Message>(_topic, ReceiveMessage, m => m...
As Mike suggested i had this and then checked the permissions. "guest" user can only connect via localhost (see RabbitMQ Access Control.) Try adding a user with permissions using the management interface and then connect as below var _bus = RabbitHutch.CreateBus(string.Format("host={0};virtualhost={1};username={2};pass...
RabbitMQ
22,882,318
12
I have a web application that uses the jquery autocomplete plugin, which essentially sends via ajax a request containing text that has been typed into a textbox to our web server, once the web server receives this request, it is then handed off to rabbitmq. I know that we do get benefits from using messaging, but it s...
It's possible to perform RPC synchronous requests with RabbitMQ. Here it's explained very well, with its drawback included! So it's considered an acceptable architecture. Discouraged, but acceptable whenever the synchronous response is mandatory. As a possible counter-effect is that adding RabbitMQ in the middle, you w...
RabbitMQ
22,797,961
12
Do RabbitMQ queues have a AWS SQS-like - "message visibility timeout" ? From the AWS SQS documentation : "The visibility timeout clock starts ticking once Amazon SQS returns the message. During that time, the component processes and deletes the message. But what happens if the component fails before deleting the messa...
I believe you are looking for the RabbitMQ manual acknowledgment feature. This feature allows you get messages from the queue and once you have receive them ack'ed them. If something happens in the middle of this process, the message will be available again in the queue after a certain amount of time. Also, in the mean...
RabbitMQ
19,410,762
12
I installed rabbitmq using homebrew. I am trying to start rabbitmq server but I always get this error which I am unable to figure out why! I have erlang installed and there is no other application running on the same port. $ rabbitmq-server {error_logger,{{2013,2,11},{22,37,49}},"Can't set short node name!\nPlease ch...
check your computer name and your short host name or alias name in /etc/hosts, match this Check your computer name [wendy@nyc123]$ nyc123 is your computer name Check your short hostname [wendy@nyc123]$ hostname -s [wendy@nyc123]$ nyc456 This error could happen because your computer name and short host name didn't ma...
RabbitMQ
14,821,675
12
I have an existing RabbitMQ deployment that that a few Java applications are using the send out log messages as string JSON objects on various channels. I would like to use Celery to consume these messages and write them to various places (e.g. DB, Hadoop, etc.). I can see that Celery is design to be both the producer...
It's currently hard to add custom consumers to the celery workers, but this is changing in the development version (to become 3.1) where I've added support for Consumer boot-steps. There's no documentation yet as I've just finished implementing it, but here's an example: from celery import Celery from celery.bin import...
RabbitMQ
12,681,802
12
I have a long-running process that must run every five minutes, but more than one instance of the processes should never run at the same time. The process should not normally run past five min, but I want to be sure that a second instance does not start up if it runs over. Per a previous recommendation, I'm using Dja...
You can use periodic tasks paired with a special lock which ensures the tasks are executed one at a time. Here is a sample implementation from Celery documentation: http://ask.github.com/celery/cookbook/tasks.html#ensuring-a-task-is-only-executed-one-at-a-time Your described method with scheduling task from the previou...
RabbitMQ
8,902,986
12
"Durable" and "persistent mode" appear to relate to reboots rather than relating to there being no subscribers to receive the message. I'd like RabbitMQ to keep messages on the queue when there are no subscribers. When a subscriber does come online, the message should be recieved by that subscriber. Is this possible ...
See the AMQP Reference for an explanation of what durable and persistent mean. Basically, queues are either durable or non-durable. The former survive broker restarts, the latter do not. Messages are published as either transient or persistent. The idea is that persistent messages on durable queues should also survi...
RabbitMQ
7,952,000
12
I am new to RabbitMQ. I want to be able to handle reading messages without blocking when there are multiple queues (to read from). Any inputs on how I can do that? //Edit 1 public class Rabbit : IMessageBus { private List<string> publishQ = new List<string>(); private List<string> subscribeQ = new List<str...
two sources of info: http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss You should really try to understand the examples first. %Program Files%\RabbitMQ\DotNetClient\examples\src (basic examples) get full working examples from their Mercurial repository (c# projects). Useful operations to underst...
RabbitMQ
6,696,694
12
I've built this sample: Getting Started With RabbitMQ in .net, but made 2 programs: one-publisher one-subscriber I'm using BasicPublish to publish and BasicAck to listen as in example. If I run one publisher and several subscribers-on every "send message" from publisher- only one subscriber gets it. So that there ...
The example you link to uses simple queueing without an exchange, which ensures that only a single consumer will handle the message. To support pub/sub in RabbitMQ, you need to first create an Exchange, and then have each subscriber bind a Queue on that Exchange. The producer then sends messages to the Exchange, which ...
RabbitMQ
5,951,477
12
I am using RabbitMQ with Django through Celery. I am using the most basic setup: # RabbitMQ connection settings BROKER_HOST = 'localhost' BROKER_PORT = '5672' BROKER_USER = 'guest' BROKER_PASSWORD = 'guest' BROKER_VHOST = '/' I imported a Celery task and queued it to run one year later. From the iPython shell: In [1]:...
Making a queue durable is not the same as making the messages on it persistent. Durable queues mean they come up again automatically when the server has restarted - which has obviously happened in your case. But this doesn't affect the messages themselves. To make messages persistent, you have to also mark the message'...
RabbitMQ
5,046,944
12
I'd like to send a message to a RabbitMQ server and then wait for a reply message (on a "reply-to" queue). Of course, I don't want to wait forever in case the application processing these messages is down - there needs to be a timeout. It sounds like a very basic task, yet I can't find a way to do this. I've now run in...
Here's what I ended up doing in the .NET client: protected byte[] WaitForMessageWithTimeout(string queueName, int timeoutMs) { var consumer = new QueueingBasicConsumer(Channel); var tag = Channel.BasicConsume(queueName, true, null, consumer); try { object result; if (!consumer.Queue.Dequ...
RabbitMQ
2,799,731
12
I have RabbitMQ setup with two queues called: low and high. I want my celery workers to consume from the high priority queue before consuming tasks for the low priority queue. I get this following error when trying to push a message into RabbitMQ >>> import tasks >>> tasks.high.apply_async() Traceback (most recent cal...
Recently I stuck with the same Issue and found this question. I decided to post possible solution for anyone else who will find it in the future. Current error message means that the queue had been declared with a priority 10, but now its signature contains a priority none. For example here is a similar issue with x-ex...
RabbitMQ
63,607,314
11
I created a microservice application that microservices using MassTransit and RabbitMQ for communication. Each microservice developed using clean architecture, so we have MediatR inside each microservice. Is it possible to use MassTransit for inside communication as well? so I can use the same signature for all service...
They can be used together, and MassTransit has its own Mediator implementation as well so you can write your handlers once and use them either via the mediator or via a durable transport such as RabbitMQ. There are videos available that take you through the capabilities, starting with mediator and moving to RabbitMQ.
RabbitMQ
62,084,208
11
I currently have a small server running in a docker container, the server uses RabbitMQ which is being run by docker-compose using the DockerHub image. It is running nicely, but I'm worried that it may not be properly configured for production (production being a simple server, without clustering or anything fancy). In...
disk_free_limit is set in /etc/rabbitmq/rabbitmq.conf, seems there is no environment available here. So, you just need to override the rabbitmq.conf with your own one with docker bind mount volume to make your aim. For your case, if you enter into the rabbitmq container, you can see: shubuntu1@shubuntu1:~$ docker exec ...
RabbitMQ
57,262,128
11
I have some images in my queue and I pass each image to my flask server where processing on images is done and a response is received in my rabbitmq server. After receiving response, I get this error "pika.exceptions.StreamLostError: Stream connection lost(104,'Connection reset by peer')". This happens when rabbitmq ch...
Your consume process is probably taking too much time to complete and send Ack/Nack to the server. Therefore, server does not receive heartbeat from your client, and thereby stops from serving. Then, on the client side you receive: pika.exceptions.StreamLostError: Stream connection lost(104,'Connection reset by peer') ...
RabbitMQ
56,859,006
11
I've got a project where we are going to have hundreds (potentially thousands) of queues in rabbit and each of these queues will need to be consumed by a pool of consumers. In rabbit (using spring-amqp), you have the rabbitlistener annotation which allows me to statically assign the queues this particular consumer(s) w...
Inject (@Autowired or otherwise) the RabbitListenerEndpointRegistry. Get a reference to the listener container (use the id attribute on the annotation to give it a known id) (registry.getListenerContainer(id)). Cast the container to an AbstractMessageListenerContainer and call addQueues() or addQueueNames(). Note tha...
RabbitMQ
54,094,994
11
I have a few microservices, which are exposed through an API-Gateway. The gateway takes care of handling authentication and routing into the system. The services behind the gateway are mostly simple CRUD-Services. Each service exposes its own API and they communicate synchronously via HTTP. All of these services, inclu...
RabbitMQ is supported in nestjs as a microservice. If you want your application to support both http requests and a message broker, you can create a hybrid application. // Create your regular nest application. const app = await NestFactory.create(ApplicationModule); // Then combine it with a RabbitMQ microservice cons...
RabbitMQ
53,995,130
11
I have the following problem: I need to test connection to RabbitMQ Server which operates on AMQ Protocol, and i need to do it using CMD or something similar, so i can execute the command from script. I don't know if it's possible,the only thing that I found on internet was testing connection through HTTP, and it does...
I found another way to verify basic tcp connectivity using just netcat/telnet. nc hostname 5672 OR telnet hostname 5672 Type HELO and hit enter 4 times. You should see a response of AMQP. example: > nc rabbitserver 5672 HELO AMQP The other tools mentioned here would verify deeper compatibility between the client ...
RabbitMQ
52,494,492
11
I've had a RabbitMQ server running for months. This morning I was unable to connect to it, my applications was timing out and the Management client was unresponsive. Rebooted the machine. Applications are still timing out. I'm able to login to the Management client but I see this message: Virtual host / experienced an...
I figured out what was going on. Someone on my team (me) was creating an unprecedented amount of connections to RabbitMQ. For each connection a file handler is created to one or more files, not sure which. The OS (Windows in my case) has a file handler limit, not sure what the limit is, but when reached, an error is th...
RabbitMQ
52,271,432
11
I'd like to use queue names using a specific pattern, like project.{queue-name}.queue. And to keep this pattern solid, I wrote a helper class to generate this name from a simple identifier. So, foo would generate a queue called project.foo.queue. Simple. But, the annotation RabbitListener demands a constant string and ...
To create and listen to a queue name constructed from a dynamic UUID, you could use random.uuid. The problem is that this must be captured to a Java variable in only one place because a new random value would be generated each time the property is referenced. The solution is to use Spring Expression Language (SpEL) to ...
RabbitMQ
49,909,859
11
I am well experienced with the RabbitMQ and AMQP protocol, and have built a system with patterns for Commands, Requests and Events. Now I am going to build a system running on AWS Lambda and therefore use SNS, SQS etc. I want to understand the "mapping" between these things. What are the equivalent to an exchange in AM...
What are the equivalent to an exchange in AMQP? The closest concept might be SNS, as you can configure a SNS topic to publish to n SQS queues. Then when you write to that topic, each subscribed queue gets a message. You can also write messages directly to SQS queues if you like. What are the equivalent to a routing ...
RabbitMQ
46,880,229
11
Say that I have this task: def do_stuff_for_some_time(some_id): e = Model.objects.get(id=some_id) e.domanystuff() and I'm using it like so: do_stuff_for_some_time.apply_async(args=[some_id], queue='some_queue') The problem I'm facing is that there are a lot of repetitive tasks with the same arg param and it's...
celery-singleton solves this requirement Caveat: requires redis broker (for distributed locks) pip install celery-singleton Use the Singleton task base class: from celery_singleton import Singleton @celery_app.task(base=Singleton) def do_stuff_for_some_time(some_id): e = Model.objects.get(id=some_id) e.doman...
RabbitMQ
45,107,418
11
I am trying to get a few messages from a queue using the HTTP API of rabbitmq. I am following the documentation in here I have no vhost configured. I tried the following curl command: curl -i -u guest:guest -H "content-type:application/json" -X POST http://127.0.0.1:15672/api/queues/foo/get -d'{"count":5,"requeue":true...
you are missing the queue name: curl -i -u guest:guest -H "content-type:application/json" -X POST http://127.0.0.1:15672/api/queues/foo/my_queue/get -d'{"count":5,"requeue":true,"encoding":"auto","truncate":50000}' where foo is the virtual host, and my_queue is the queue name. as result: [ { "payload_bytes":4...
RabbitMQ
43,513,681
11
I have implemented the example from the RabbitMQ website: RabbitMQ Example I have expanded it to have an application with a button to send a message. Now I started two consumer on two different computers. When I send the message the first message is sent to computer1, then the second message is sent to computer2, the t...
Why is this As noted by Yazan, messages are consumed from a single queue in a round-robin manner. The behavior your are seeing is by design, making it easy to scale up the number of consumers for a given queue. how can I change the behavior to send each message to each consumer? To have each consumer receive the s...
RabbitMQ
41,160,585
11
I'm looking for a solution to have scheduled messages with RabbitMQ, so not only delaying the messages as described in several sources but schedule it to have a message e.g. every day. If not RabbitMQ, any other solutions out there you can think of and you'd suggest for a microservices environment using a message-bus? ...
Or is it better to use a job scheduler just to push messages to the message queue, e.g. using rundeck in combination with RabbitMQ? yes. RabbitMQ is not designed to handle scheduling, and attempting to use it for that will just be painful (at best). It is best to use another scheduling system, like cron jobs or runde...
RabbitMQ
40,807,355
11
I'm required to create a simple queue manager to pass a number from a sender to a consumer. Hello World tutorial provided by RabbitMQ covers almost 70% of it. But I need to change the queue to not to forever waiting for incoming messages. Or stop waiting after certain amount of messages. I read and tried few solutions ...
Modify wait() in while loop: $timeout = 55; while(count($channel->callbacks)) { $channel->wait(null, false, $timeout); }
RabbitMQ
33,930,923
11
Let's just accept for a moment that it is not a horrible idea to implement RPC over message queues (like RabbitMQ) -- sometimes it might be necessary when interfacing with legacy systems. In case of RPC over RabbitMQ, clients send a message to the broker, broker routes the message to a worker, worker returns the result...
Let's just accept for a moment that it is not a horrible idea to implement RPC over message queues (like RabbitMQ) it's not horrible at all! it's common, and recommended in many situations - not just legacy integration. ... ok, to your actual question now :) from a very high level perspective, here is what you need ...
RabbitMQ
31,687,652
11
I wondering why my RabbitMQ RPC-Client always processed the dead messages after restart. _channel.QueueDeclare(queue, false, false, false, null); should disable buffers. If I overload the QueueDeclare inside the RPC-Client I can't connect to the server. Is something wrong here? Any idea how to fix this problem? RPC-Se...
Try setting the DeliveryMode property to non-persistent (1) in your RPC-Client code like this: public Message Call(Message message) { ... var props = _channel.CreateBasicProperties(); props.DeliveryMode = 1; //you might want to do this in your RPC-Server as well ... } AMQP Model Explained contains very use...
RabbitMQ
31,369,854
11
At first glance I liked very much the "Batches" feature in Celery because I need to group an amount of IDs before calling an API (otherwise I may be kicked out). Unfortunately, when testing a little bit, batch tasks don't seem to play well with the rest of the Canvas primitives, in this case, chains. For example: @a.ta...
Looks like the behaviour of batch tasks is significantly different from normal tasks. Batch tasks are not even emitting signals like task_success. Since you need to call completed task after get_price, You can call it directly from get_price itself. @a.task(base=Batches, flush_every=10, flush_interval=5) def get_price(...
RabbitMQ
31,360,918
11
I'm trying to move away from SQS to RabbitMQ for messaging service. I'm looking to build a stable high availability queuing service. For now I'm going with cluster. Current Implementation , I have three EC2 machines with RabbitMQ with management plugin installed in a AMI , and then I explicitly go to each of...
I had a similar configuration 2 years ago. I decided to use amazon VPC, by default my design had two RabbitMQ instances always running, and configured in cluster (called master-nodes). The rabbitmq cluster was behind an internal amazon load balancer. I created an AMI with RabbitMQ and management plug-in configured (ca...
RabbitMQ
31,340,413
11
Please, imagine you have a method like the following: public void PlaceOrder(Order order) { this.SaveOrderToDataBase(order); this.bus.Publish(new OrderPlaced(Order)); } After the order is saved to the database, an event is published to the message queuing system, so other subsystems on the same or anothe...
The correct way to ensure the event is eventually published to the message queuing sytem is explained in this video and on this blog post Basically you need to store the message to be sent into the database in the same transaction you perform the bussines logic operation, then send the message to the bus asynchronously...
RabbitMQ
30,780,979
11
I am using Unity App Block as my IOC container for my service layer of a WCF project. This works quite well using the Unity.WCF library to plug it into each WCF service. I recently introduced RabbitMQ into my service layer and I am currently using the "using" blocks to connect and add to the queue. I dont like this ...
I would advise registering the IConnection as a singleton. To register the IConnection as a singleton in Unity you would use a ContainerControlledLifetimeManager, e.g. var connectionFactory = new ConnectionFactory { // Configure the connection factory }; unityContainer.RegisterInstance(connectionFactory); unityCon...
RabbitMQ
29,985,065
11
Im using amqp.node library to integrate rabbitmq into my system. But in consumer i want to process just one message at the time, then acknowledge the message then consume the next message from the queue. The current code is: // Consumer open.then(function(conn) { var ok = conn.createChannel(); ok = ok.then(function...
At this moment (2018), I think RabbitMQ team has an option to do that: https://www.rabbitmq.com/tutorials/tutorial-two-javascript.html ch.prefetch(1); In order to defeat that we can use the prefetch method with the value of 1. This tells RabbitMQ not to give more than one message to a worker at a time. Or, in oth...
RabbitMQ
28,747,192
11
All the examples in pika tutorial end with the client invoking start_consuming(), which starts an infinite loop. These examples work for me. However, I do not want my client to run forever. Instead, I need my client to consume messages for some time, such as 15 minutes, then stop. How do I accomplish that?
You can consume messages one at a time with your own loops, say you have a channel and queue setup. The following will check if the queue is empty, and if not, pop a single message off of it. queue_state = channel.queue_declare(queue, durable=True, passive=True) queue_empty = queue_state.method.message_count == 0 decl...
RabbitMQ
26,977,708
11
I create vhost: rabbitmqctl add_vhost test Then user: rabbitmqctl add_user user 123456 Then I take permissions to that user: rabbitmqctl set_permissions -p test user "test" "test" "test" I use Celery, in tasks.py: app = Celery('tasks', broker='amqp://user:123456@localhost/test', backend='amqp://user:123456@localhost...
Take a look at set_permissions here: https://www.rabbitmq.com/rabbitmqctl.8.html#Access_control When you call set_permissions you are passing "test" for configure, read and write, so your user will be able to only use a queue/exchange by the name "test" Also, take a look at this link as well: https://www.rabbitmq.com/a...
RabbitMQ
26,471,231
11
I'm learning how to use rabbitMQ. I'm running the rabbit-MQ server on my MacBook and trying to connect with a python client. I followed the installation instructions here. And now I'm performing the tutorial shown here. The tutorial says to run this client: #!/usr/bin/env python import pika connection = pika.BlockingC...
The client is trying to connect using IPv6 localhost (::1:5672), while the server is listening to IPv4 localhost ({"127.0.0.1",5672}). Try changing the client to connect to the IPv4 localhost instead; connection = pika.BlockingConnection(pika.ConnectionParameters('127.0.0.1'))
RabbitMQ
24,103,758
11
Looking for some code samples to solve this problem :- Would like to write some code (Python or Javascript) that would act as a subscriber to a RabbitMQ queue so that on receiving a message it would broadcast the message via websockets to any connected client. I've looked at Autobahn and node.js (using "amqp" and "ws...
One way to implement your system is use python with tornado. Here the server: import tornado.ioloop import tornado.web import tornado.websocket import os import pika from threading import Thread clients = [] def threaded_rmq(): connection = pika.BlockingConnection(pika.Connect...
RabbitMQ
22,862,970
11
I've been watching Rick Branson's PyCon video: Messaging at Scale at Instagram. You might want to watch the video in order to answer this question. Rick Branson uses Celery, Redis and RabbitMQ. To get you up to speed, each user has a redis list for their homefeed. Each list contains media ID's of photos posted by the p...
The approach described in the video is task "chaining". To get your task method up and running as a chain, you want to add an extra parameter that represents the index into the list of followers. Instead of working on the full list of followers, the task only works on a fixed batch size, starting from the index argumen...
RabbitMQ
21,007,096
11
I want my email service that I wrote to be completely decoupled from my flask application. I am using celery with rabbitmq. So I am wondering is there a way I can configure celery so that in one project I have the Flask application that sends the message to the queue (producer). And in another project I have the celery...
You can use Celery's send_task function to send the task through RabbitMQ to the worker using the task name. You still need to import the module that you have the celery app in: If the task is not registered in the current process you can use send_task() to call the task by name instead. Example: from yourmodule.yo...
RabbitMQ
19,643,774
11
I have converted a standalone batch job to use celery for dispatching the work to be done. I'm using RabbitMQ. Everything is running on a single machine and no other processes are using the RabbitMQ instance. My script just creates a bunch of tasks which are processed by workers. Is there a simple way to measure the ti...
You could use celery signals, functions registered will be called before and after a task is executed, it is trivial to measure elapsed time: from time import time from celery.signals import task_prerun, task_postrun d = {} @task_prerun.connect def task_prerun_handler(signal, sender, task_id, task, args, kwargs, **e...
RabbitMQ
19,481,470
11
I'm in a phase of learning RabbitMQ/AMQP from the RabbitMQ documentation. Something that is not clear to me that I wanted to ask those who have hands-on experience. I want to have multiple consumers listening to the same queue in order to balance the work load. What I need is pretty much close to the "Work Queues" exam...
No, the other consumers don't get blocked. Other messages will get delivered even if they have unacknowledged but delivered predecessors. If a channel closes while holding unacknowledged messages, those messages get returned to the queue. See RabbitMQ Broker Semantics Messages can be returned to the queue using AMQP m...
RabbitMQ
17,841,843
11
I am using Python3 and I want to use RabbitMQ. I already tried to use Pika, and txAMQP but they do not support Python 3. Have anybody an idea how I can use RabbitMQ.
Check this page https://github.com/hollobon/pika-python3 May be it can help you.
RabbitMQ
15,655,189
11
I am able to create a fanout exchange using the Publish/Subscribe RabbitMQ Java tutorial, and any connected consumer will receive a copy of a message. Instead of declaring an exchange and binding dynamically/programmatically, I would like to create the exchange and the binding prior to connecting any consumers. I have ...
It sounds like all of your consumers are subscribing to the same queue. When multiple consumers are subscribing to the same queue, the default behavior of RabbitMQ is to round-robin the messages between all the subscribed consumers. See "Round-robin dispatching" in the RabbitMQ Tutorial #2: Work Queues. The fanout ex...
RabbitMQ
15,342,340
11
I want to upload images to S3 server, but before uploading I want to generate thumbnails of 3 different sizes, and I want it to be done out of request/response cycle hence I am using celery. I have read the docs, here is what I have understood. Please correct me if I am wrong. Celery helps you manage your task queues ...
IronMQ does not process your tasks for you; it simply serves as the backend for Celery to keep track of what jobs need to be performed. So, here's what happens. Assume you have two servers, your web server and your Celery server. Your web server is responsible for handling requests, your Celery server creates the thumb...
RabbitMQ
15,121,519
11