-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RSWW-134 set up rabbitmq communication for hotels
- Loading branch information
1 parent
5b85468
commit a23ac73
Showing
4 changed files
with
110 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
data-generator/src/main/java/cloud/project/datagenerator/hotels/rabbitmq/QueuesConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cloud.project.datagenerator.hotels.rabbitmq; | ||
|
||
import org.springframework.amqp.core.FanoutExchange; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class QueuesConfig { | ||
public static final String EXCHANGE_HOTEL_FANOUT_UPDATE_DATA = "data.generate.hotels.exchange"; | ||
|
||
@Bean | ||
public FanoutExchange updateHotelDataFanoutExchange() { | ||
return new FanoutExchange(EXCHANGE_HOTEL_FANOUT_UPDATE_DATA); | ||
} | ||
|
||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...nerator/src/main/java/cloud/project/datagenerator/hotels/rabbitmq/json/JsonConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package cloud.project.datagenerator.hotels.rabbitmq.json; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; | ||
|
||
public class JsonConverter { | ||
public static String convert(Object obj) { | ||
ObjectMapper mapper = new ObjectMapper().registerModule(new JavaTimeModule()); | ||
String json; | ||
try { | ||
json = mapper.writeValueAsString(obj); | ||
|
||
} catch (JsonProcessingException e) { | ||
e.printStackTrace(); | ||
throw new RuntimeException("Json failed to convert to JSON."); | ||
} | ||
return json; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...src/main/java/cloud/project/datagenerator/hotels/rabbitmq/requests/RoomUpdateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package cloud.project.datagenerator.hotels.rabbitmq.requests; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.UUID; | ||
|
||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
public class RoomUpdateRequest { | ||
|
||
private String updateType; | ||
|
||
private UUID id; | ||
|
||
private UUID hotelId; | ||
|
||
private String name; | ||
|
||
private int guestCapacity; | ||
|
||
private float pricePerAdult; | ||
|
||
private String description; | ||
|
||
// List of room reservations for each room is empty | ||
} |