I have a two instances of one spring boot microservice. If two requests are sent at the same time, and the second request can update the row that was created by the first request. How i can prevent this? For example the table contains this columns :id,format,username,groupName and if a row exists (3,”test”,”test”,”test”) and if we try to insert another
Tag: spring
Starting and Stopping an InboundChannelAdapter manually
I’m trying to start an InboundChannelAdapter manually using a @Scheduled function. I think I’m setting up the message payload wrong but I’m not sure what to have it as. Here’s the code: I’m getting this error: The error occurs at the controlBusChannel.send() line and the transformer in the error is the first one that runs after the source. How do
How to define a bean from a dependency class as @Primary in Spring?
I have a Kafka Consumer and I’m implementing it using the Spring Cloud Stream Source.class binding and InboundChannelAdapter. This Source.class defines 3 MessageChannel beans: output, nullChannel, and errorChannel. My code looks like this: I want to autowire in the output channel so that I can use it to start and stop my InboundChannelAdapter manually, but I’m getting this error when
How to loop through a list payload and insert into database as individual row items in Springboot?
I am trying to insert items in a list in a database as single values in rows with the name of the sender. I am able to send the payload and insert into a single row with the user detailst. How can I loop through the payload sent and insert all the items into individual rows? I have tried to
Hibernate Native SQL returns some nulls instead of partially filled objects
I have the following (postgress) SQL Query: And what it does is it creates a series of 6 hours per day and takes averages from it. A result may look like this: variable_id date_time sample_count sample_period_ms min_value max_value value 15 2021-06-06 06:00:00 120 59577 -1.4960686 1.1995025 0.30439844254136744 15 2021-06-06 12:00:00 120 59577 -1.4887594 1.1997863 0.30570657099738263 15 2021-06-06 18:00:00 120 59577
400 Bad Request when using Spring Boot
I am sending a Http POST request to my RESTful API build with Spring Boot and get the “400 Bad Request” response. My POST request is made with Postman, send to with the body I want to pass the filename variable to my Java Method. My RESTful api is build in Java with Spring Boot I tried with and with
Fetching to substring before operator from a dynamic string
I have a string like “name = mita and salary> 10000” . Out of which I need to get only name and salary attribute.I am going to have dynamic string on which i need the attribute before operator only. Like here I need to fetch name and salary attribute which r before = and > operator. I can have multiple
Testing a Spring ControllerMethod using Mockito which alters an entry in the db with Optional.map NullPOinterException
Im currently Testing my Controller methods. In one Method I add a Reisepunkt(travelpoint) to a Reise(travel), which is already saved inside a database. Using the generated-request.http API I can use the method to make entrys into the db. Now i wanted to write a test method just so I can get the hang of it. I always get a NullPointerException
Spring kstreams cannot get processor to work – The class ‘[B’ is not in the trusted packages
Full code: https://github.com/BenedictWHD/kstreams-example So I have a producer (data-ingest), processor (external-message-processor), and consumer (internal-message-processor (This will become a processor later once I get things working, so apologies for the naming at the moment, but it is a consumer)). The data-ingest works from what I can tell as it sends messages to the topic external_messages. The external-message-processor attempts to read from
Spring:- What is the difference between ref attribute and ref tag?
I am pretty new to spring and have been learning from the official docs. I found that to inject a dependency using XML configuration, there are two ways to declare refs:- Or, I can use the ref tag, like:- Is there any difference between the two ref declarations? If not, why does spring allow two different methods? Thanks in advance.