11 changed files with 180 additions and 40 deletions
Unified View
Diff Options
-
11UB_OrderServiceProxy/pom.xml
-
48UB_OrderServiceProxy/src/main/java/com/example/urbanbazaar/config/MessagingConfig.java
-
14UB_OrderServiceProxy/src/main/java/com/example/urbanbazaar/controller/OrderController.java
-
59UB_OrderServiceProxy/src/main/java/com/example/urbanbazaar/model/OrderStatus.java
-
11UB_OrderServiceProxy/src/main/java/com/example/urbanbazaar/model/Orders.java
-
2UB_OrderServiceProxy/src/main/java/com/example/urbanbazaar/repository/OrderRepository.java
-
9UB_OrderServiceProxy/src/main/resources/application.properties
-
2UB_UserServiceProxy/src/main/java/com/example/urbanbazaar/UbUserServiceProxyApplication.java
-
41UB_UserServiceProxy/src/main/java/com/example/urbanbazaar/controller/UserController.java
-
22grocery_db_tables.sql
-
1springboot-rabbitmq-example
@ -0,0 +1,48 @@ |
|||||
|
package com.example.urbanbazaar.config; |
||||
|
|
||||
|
import org.springframework.amqp.core.AmqpTemplate; |
||||
|
import org.springframework.amqp.core.Binding; |
||||
|
import org.springframework.amqp.core.BindingBuilder; |
||||
|
import org.springframework.amqp.core.Queue; |
||||
|
import org.springframework.amqp.core.TopicExchange; |
||||
|
import org.springframework.amqp.rabbit.connection.ConnectionFactory; |
||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
||||
|
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; |
||||
|
import org.springframework.amqp.support.converter.MessageConverter; |
||||
|
import org.springframework.context.annotation.Bean; |
||||
|
import org.springframework.context.annotation.Configuration; |
||||
|
|
||||
|
@Configuration |
||||
|
public class MessagingConfig { |
||||
|
|
||||
|
public static final String QUEUE = "team_berlin_gs"; |
||||
|
public static final String EXCHANGE = "team_berlin_exchange"; |
||||
|
public static final String ROUTING_KEY = "team_berlin_routingKey"; |
||||
|
|
||||
|
@Bean |
||||
|
public Queue queue() { |
||||
|
return new Queue(QUEUE); |
||||
|
} |
||||
|
|
||||
|
@Bean |
||||
|
public TopicExchange exchange() { |
||||
|
return new TopicExchange(EXCHANGE); |
||||
|
} |
||||
|
|
||||
|
@Bean |
||||
|
public Binding binding(Queue queue, TopicExchange exchange) { |
||||
|
return BindingBuilder.bind(queue).to(exchange).with(ROUTING_KEY); |
||||
|
} |
||||
|
|
||||
|
@Bean |
||||
|
public MessageConverter converter() { |
||||
|
return new Jackson2JsonMessageConverter(); |
||||
|
} |
||||
|
|
||||
|
@Bean |
||||
|
public AmqpTemplate template(ConnectionFactory connectionFactory) { |
||||
|
final RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory); |
||||
|
rabbitTemplate.setMessageConverter(converter()); |
||||
|
return rabbitTemplate; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,59 @@ |
|||||
|
package com.example.urbanbazaar.model; |
||||
|
|
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
import lombok.ToString; |
||||
|
|
||||
|
@Data |
||||
|
@AllArgsConstructor |
||||
|
@NoArgsConstructor |
||||
|
@ToString |
||||
|
public class OrderStatus { |
||||
|
|
||||
|
private Orders order; |
||||
|
private String status;//progress,completed |
||||
|
private String message; |
||||
|
|
||||
|
public Orders getOrder() { |
||||
|
return order; |
||||
|
} |
||||
|
|
||||
|
public void setOrder(Orders order) { |
||||
|
this.order = order; |
||||
|
} |
||||
|
|
||||
|
public String getStatus() { |
||||
|
return status; |
||||
|
} |
||||
|
|
||||
|
public void setStatus(String status) { |
||||
|
this.status = status; |
||||
|
} |
||||
|
|
||||
|
public String getMessage() { |
||||
|
return message; |
||||
|
} |
||||
|
|
||||
|
public void setMessage(String message) { |
||||
|
this.message = message; |
||||
|
} |
||||
|
|
||||
|
public OrderStatus() { |
||||
|
super(); |
||||
|
// TODO Auto-generated constructor stub |
||||
|
} |
||||
|
|
||||
|
public OrderStatus(Orders order, String status, String message) { |
||||
|
super(); |
||||
|
this.order = order; |
||||
|
this.status = status; |
||||
|
this.message = message; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public String toString() { |
||||
|
return "OrderStatus [order=" + order + ", status=" + status + ", message=" + message + "]"; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
Subproject commit 10a0271fcba7f90b09523ad74703297c45b2b620 |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue